1
我正在開發一個windows form
,其中包含兩個控件Textbox
和Datagridview
。向下和向上箭頭鍵不滾動DataGridView中的當前單元格
現在,當我第一次打開窗體焦點應該在文本框,如果我輸入的東西它應該被附加到文本框。
如果我按UP/Down arrow key
重點應在DataGridview
和Highlight
應該移動到下一行。
但問題是它只將焦點設置爲gridview
但不選擇下一行。它滾動down/UP on next key press
。如果注意力集中在GridView
和if I start typing alphabets it should be appended to TextBox text
上,它也是一樣,但這裏它也只將焦點設置爲textbox
,而在另一按鍵上它開始在其中輸入文本。
如何實現這個?我現在用
代碼是:
if (e.KeyCode== Keys.Down)
{
this.DgAppDetails.Focus();
int index = DgAppDetails.CurrentCell.RowIndex;
if (index != DgAppDetails.Rows.Count - 1)
{
if (i == 0)
{
DgAppDetails.CurrentCell = DgAppDetails.Rows[index+1].Cells[0];
i++;
}
}
}
else if(e.KeyCode==Keys.Up)
{
this.DgAppDetails.Focus();
int index = DgAppDetails.CurrentCell.RowIndex;
if (index != 0)
{
if (i == 0)
{
DgAppDetails.CurrentCell = DgAppDetails.Rows[index - 1].Cells[0];
i++;
}
}
}
你有代碼的例子..?你也設置像'control.Focus()?[MSDN Control.Focus()方法](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.focus .aspx)你在DataGridView中輸入什麼事件..? – MethodMan