I went into problem: I have two DataGridView
on my form MAIN and SUB, now here is what I want to do that if MAIN DataGridView
cell is in edit mode and user press the down arrow then instead of going down to next row in MAIN DataGridView
it should step to next row in SUB DataGridView
I have created an event on EditingControlShowing
by handling the PreviewKeyDown
but it works only if there is one row in MAIN DataGridView
or i am on the Last row in MAIN dataGridView but if there are more then one row in MAIN DataGridView
then if i press Arrow Up or Arrow Down it moves through MAIN DataGridView
Rows only.
I have tried to control it at DataGridView
peviewKey but arrow keys does not register there, also Arrow Keys does not register at DataGridView
KeyDown
and keypress
while in edit mode
they are registered at keyup of DataGridView
but at this point it do two thing move the rows down or up in both dataGridViews
what I want that if MAIN DataGridView
cell is in editmode and up or down arrow key are pressed then it only change the row in SUB DataGridView
not in main DataGridView
Any Ideas!
Have you tried programmatically selecting rows in the sub dataGridView? You can try getting the index of the selected row in the sub grid when the Main PreviewKeyDown event fires and then selecting the next sub dataGridView row like this for example:
subDataGridView.Rows(index).Selected = False
subDataGridView.Rows(index + 1).Selected = True
or maybe
subDataGridView.CurrentCell = DataGridView1.Rows(index + 1).Cells(0);
通过覆盖“ dataGridView”并在此处创建自定义列的解决方案来解决此问题:在此处输入链接描述就像一个魅力一样。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.