I am having a combo box and a textbox in my datagridview. What i would like to do is when i select a value from combo box and moves to the text box by using Tab i would like to display the selected value from the combo box in to that text box.
I tried by writing a dummy code in TabIndexchanged it does not work so can any one help me


Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Mar 7, 2011, 1:51 AM EST
There is no TabIndex property in DataGridTextBoxColumn and DataGridComboBoxColumn.
So you cant set the focus by pressing TAB i guess.
Suthish NairRank #92 · 22.8K reputationPosted Mar 7, 2011, 9:53 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Mar 7, 2011, 4:49 PM EST
If it is a necessity that you not change the value in the TextBox until the focus moves to the TextBox, then you could do that using the Enter event for the TextBox. That will work regardless of how the focus moves to the TextBox.
Dorababu MekaRank #457 · 5.5K reputationPosted Mar 7, 2011, 6:24 PM EST
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
str = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
}
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.CurrentRow.Cells["Txt"].Value = str;
}