I want to view a datagridview textbox column containing values from different table. So that I can choose one of the value and other columns should filled according to those values.
I already use combo Box Column for the above case, its working but I want to press enter to move to next column, don't want to use tab key to move to next cell. and want to use tab key to move to next control in tab sequence.
I am using c#.net 2.0 and and .mdf file in sql express 2005.
Please help.
If possible then help me with some Project.
I will be very great full to you. Sorry Sir,
is working on other column as it was but not working with combo box column. Combox column of Data grid view is not Listening any KeyDown Event. I didn't got my answer.
Code is for datagrid view to add combobox column and other column is:
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Store.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=true;";
con.Open();
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.MultiSelect = false;
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
SqlDataAdapter da = new SqlDataAdapter("Select SlNoFoodName,Unit,Quantity ,Total from KOT where KOTNo='"+textBox1.Text +"' and date= '"+dtp1+"'", con);
DataSet ds = new DataSet();
da.Fill(ds, "KOT");
dataGridView1.DataSource = ds.Tables[0];
SqlCommand cmd4 = new SqlCommand("select Code from FoodTable", con);
SqlDataReader dr4 = cmd4.ExecuteReader();
while (dr4.Read())
cmb.Items.Add(dr4[0].ToString());
dataGridView1.Columns.Insert(1, cmb);
dr4.Close();
con.Close();
Please Help
Sorry for the delay.
Because I don't had the Internet Connetions.
Please Please private void dataGridView1_KeyDown( object sender, KeyEventArgs e) if (e.KeyCode == Keys.Enter) e.SuppressKeyPress = true ; dataGridView1.CurrentCell = dataGridView1.CurrentRow.Cells[dataGridView1.CurrentCell.Index + 1]; else if (e.KeyCode == Keys.Tab) e.SuppressKeyPress = true ; NextControl.Select(); where NextControl is the new control you want to select.
I hope this help,
Good Luck,
I think you may have to use the KeyDown event and check for the ENTER key, then programmatically move to the next column. The KeyPress event only works on character keys.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx [ ^ ]
I alreadly tried the keypress, keydown and keyup events with the properties like keychar , keyvalue and so on. But i am not getting what I want.
Actually, I want to move to next cell in the same row using enter key, that works with TAB key.
Other cells are listining to keydown event but the combobox cell is not listning the event. and when I press enter it goes down to the next row and in the same column. I want same row and next column.
Please help
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Enter)
e.SuppressKeyPress = true;
dataGridView1.CurrentCell = dataGridView1.CurrentRow.Cells[dataGridView1.CurrentCell.Index + 1];
else if (e.KeyCode == Keys.Tab)
e.SuppressKeyPress = true;
NextControl.Select();
</code>
dataGridView1.CurrentCell = dataGridView1.CurrentRow.Cells[dataGridView1.CurrentCell.Index + 1];
this line of code is which you want,
the meaning of the code is if you press Enter CurrentCell will move to next!!
try it!
GoodLuck!
-Wayne
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •