views:

611

answers:

2

I want to programmatically set the focus to the last row (bottommost, its only one column wide) in the DataGridView control for Visual Basic. How can I do so?

So far, I have tried

DGV.Rows.GetLastRow(DataGridViewElementStates.Selected)

without success, though I did not expect that to work.

It absolutely must select that last cell. Otherwise, the application is nearly impossible to use!

Here is a screenshot of what I am making with this: http://www.mediafire.com/?mmyogzytgzt

The "Paste Clipboard Contents" button only pastes into the selected cell, though I guess I could find a workaround.

A: 

I solved it. I used a workaround to add the text in directly. I don't need this anymore!

Cyclone
A: 

To select the last column, last row in c# (sorry I don't have a vb project I'm working right now:

this._dg.ClearSelection(); // eliminates what they already have selected if you need
this._dg[this._dg.ColumnCount-1, this._dg.RowCount-1].Selected = true;

In VB.net replace 'this' with 'me', and [] with ().

This is also useful:

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
Maslow