Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 在Visual Basic中以编程方式设置DataGridView控件的焦点_Vb.net_Datagridview - Fatal编程技术网

Vb.net 在Visual Basic中以编程方式设置DataGridView控件的焦点

Vb.net 在Visual Basic中以编程方式设置DataGridView控件的焦点,vb.net,datagridview,Vb.net,Datagridview,我希望通过编程将焦点设置为Visual Basic的DataGridView控件中的最后一行(最底部,只有一列宽)。我怎样才能做到 到目前为止,我已经试过了 DGV.Rows.GetLastRow(DataGridViewElementStates.Selected) 没有成功,尽管我没想到会成功 它绝对必须选择最后一个单元格。否则,应用程序几乎无法使用 下面是我用这个制作的屏幕截图: “粘贴剪贴板内容”按钮只粘贴到选定的单元格中,不过我想我可以找到解决办法。我解决了这个问题。我使用了一种变通

我希望通过编程将焦点设置为Visual Basic的DataGridView控件中的最后一行(最底部,只有一列宽)。我怎样才能做到

到目前为止,我已经试过了

DGV.Rows.GetLastRow(DataGridViewElementStates.Selected)
没有成功,尽管我没想到会成功

它绝对必须选择最后一个单元格。否则,应用程序几乎无法使用

下面是我用这个制作的屏幕截图:


“粘贴剪贴板内容”按钮只粘贴到选定的单元格中,不过我想我可以找到解决办法。

我解决了这个问题。我使用了一种变通方法来直接添加文本。我不再需要这个了

选择c#中的最后一列、最后一行(很抱歉,我没有vb项目,我正在工作:

this._dg.ClearSelection(); // eliminates what they already have selected if you need
this._dg[this._dg.ColumnCount-1, this._dg.RowCount-1].Selected = true;
在VB.net中,将“this”替换为“me”,将[]替换为()

这也很有用:

this._dg.Focus();
this._dg.CurrentCell = this._dg[this._dg.ColumnCount - 1, this._dg.RowCount - 1];
this._dg.BeginEdit(false); // true if you want all text highlighted 
  // for deletion or replacement