Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

datagridview usedrcontrol cell Issue

$
0
0

i created usercontrol ( textbox and Combobox) and added to datagridview first row ,

if i clicked in Combobox cell 0 then go to cell 1 then comeback to cell 0 

the datagridview.currentcell.columnindex stayed in cell 1 

i mean the cellclick fires only first time clicking the cell . if i clicked again to change the value of combobox it not fire again !!

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {

 Type CurrentCellDataType = dataGridView1.Columns[e.ColumnIndex].ValueType;
                    if (e.RowIndex == 0)
                {
                    if ((CurrentCellDataType.Name != "DateTime" &&
                         CurrentCellDataType.Name != "DateTime2" &&
                         CurrentCellDataType.Name != "Date"))
                    {
                    
                        txbComboControl = new TextWithComboControl();
                        txbComboControl.RightToLeft = this.RightToLeft;
                        txbComboControl.Visible = false;
                        dataGridView1.Controls.Add(txbComboControl);
                        txbComboControl.textbox1.KeyPress += new KeyPressEventHandler(txbComboControl_OnKeyPress);

                        Rectangle rect = this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                        txbComboControl.Location = rect.Location;
                        txbComboControl.Size = rect.Size;
                        txbComboControl.FilterText = this.dataGridView1.CurrentCell.Value.ToString();
                        if (OperationValue != "")
                            txbComboControl.SelectedOperation = OperationValue;

                        txbComboControl.renderControl();
                        txbComboControl.Visible = true;

                        txbComboControl.textbox1.TextChanged += new EventHandler(txbComboControl_OnTextChange);
                        txbComboControl.OperationBox.SelectedValueChanged += new EventHandler(txbComboControl_OnCmboTextChange);
                    }

}


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>