none
DataGridView 编辑单元格输入内容,弹出下拉datagridview检索信息。 RRS feed

  • Question

  • 我在编辑一个datagridview1单元格时,输入拼音字母,弹出下拉datagridview2按照单元格输入的拼音字母检索信息。

    private void dgvDiagnose_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
          if (e.Control.GetType().Equals(typeof(DataGridViewTextBoxEditingControl)))//cell为类TextBox时
          {
    
            editingControl = e.Control as DataGridViewTextBoxEditingControl;
            ucInput inputDiag = ucInput.GetInstance();
            inputDiag.Name = "input";
            inputDiag.setOwner(this.Controls, (TextBox)editingControl);
            inputDiag.loadData();
            this.Controls.Add(inputDiag);
            inputDiag.Location =
              new System.Drawing.Point((this.dgvDiagnose.Location.X
              + this.dgvDiagnose.GetCellDisplayRectangle(this.dgvDiagnose.CurrentCell.ColumnIndex, this.dgvDiagnose.CurrentCell.RowIndex, false).X), (this.dgvDiagnose.Location.Y
              + this.dgvDiagnose.GetCellDisplayRectangle(this.dgvDiagnose.CurrentCell.ColumnIndex, this.dgvDiagnose.CurrentCell.RowIndex, true).Y
              + 23));
            inputDiag.BringToFront();
            inputDiag.filter();
    
            editingControl.PreviewKeyDown += new PreviewKeyDownEventHandler(editingControl_PreviewKeyDown);
          }
        }
        private void editingControl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
          switch (e.KeyData)
          {
            case Keys.Left:
              break;
            case Keys.Up:
              break;
            case Keys.Down:
    
              break;
            case Keys.Right:
              break;
            case Keys.Home:
              break;
            case Keys.End:
              break;
            case Keys.PageDown:
              break;
            case Keys.PageUp:
              break;
          }
        }
    

    现在是可以检索信息,

    但是现在使用下键,不跳到datagridview2中,而是在datagridiview1跳到下一单元格

    (我想使用下键跳到弹出的datagridview2中,使用上、下键选择需要的信息,回车把内容跳到datagridview1中编辑的单元格中。)

    求教

    Wednesday, June 22, 2011 1:52 AM