按键输入事件不在gridlookupedit devexpress中工作

时间:2016-12-08 10:48:03

标签: c#

我正在使用gridlookupedit控件,但是这里有一个问题就是我正在从gridlookupedit视图中填充文本框。当我按下回车键时,我的行索引更改为默认为0。

这是我试过的代码:

private void GridLookUpEdit_KeyPress(object sender, KeyPressEventArgs e) {
    try {
        if (e.KeyChar == 13) {
            GridLookUpEdit_Click(sender, e);
        }
    } catch (Exception ex) {
        MessageBox.Show(ex.Message);
    }
}

private void GridLookUpEdit_Click(object sender, EventArgs e) {
    try {
        if (sender.Equals(GDrGroup) == true) {
            dec.FillTextBox(gridDrGroup, GDrGroup, new Control[]{txtDrGroupName});
            gridDrParty.Focus();
            gridDrParty.ShowPopup();
        }
        if (sender.Equals(GDrParty) == true) {
            dec.FillTextBox(gridDrParty, GDrParty, new Control[]{txtDrPartyName});
            txtDrCom.Focus();
        }
        if (sender.Equals(GCrGroup) == true) {
            dec.FillTextBox(gridCrGroup, GCrGroup, new Control[]{txtCrGroupName});
            gridCrParty.Focus();
            gridCrParty.ShowPopup();
        }
        if (sender.Equals(GCrParty) == true) {
            dec.FillTextBox(gridCrParty, GCrParty, new Control[]{txtCrPartyName});
            txtCrCom.Focus();
        }
    } catch (Exception ex) {
        MessageBox.Show(ex.Message);
    }
}

public void FillTextBox(GridLookUpEdit gridlookupedit, GridView view, Control[] con) {
    try {
        if (gridlookupedit.EditValue == null) return;

        for (int i = 0; i <= con.Length - 1; i++) {
            for (int j = 0; j <= view.Columns.Count - 1; j++) {
                con[i].Text = view.GetRowCellValue(view.FocusedRowHandle, view.Columns[j]).ToString();
            }
            gridlookupedit.ClosePopup();
        }
    } catch (Exception ex) {
        MessageBox.Show(ex.Message);
    }
}

0 个答案:

没有答案