VB.Net progam the selecting of a row of a DataGridView

  • Thread starter News.Individual.NET
  • Start date
N

News.Individual.NET

Hi all,

I can detect the active row (iRowIndex: see below please) and do whatever I
want, but I do not seem to be able to set a row to be selected.

How can I do that in vb.Net?

Private Sub DataGridView1_MouseDown(etc.....

Dim btnLeft = Windows.Forms.MouseButtons.Left

If e.Button = btnLeft Then

Dim hit As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
If hit.Type = DataGridViewHitTestType.Cell Then
clickedCell = DataGridView1.Rows(hit.RowIndex).Cells(hit.ColumnIndex)
iRowIndex = CInt(hit.RowIndex)
etc...
 
J

Jack Jackson

Hi all,

I can detect the active row (iRowIndex: see below please) and do whatever I
want, but I do not seem to be able to set a row to be selected.

How can I do that in vb.Net?

Private Sub DataGridView1_MouseDown(etc.....

Dim btnLeft = Windows.Forms.MouseButtons.Left

If e.Button = btnLeft Then

Dim hit As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
If hit.Type = DataGridViewHitTestType.Cell Then
clickedCell = DataGridView1.Rows(hit.RowIndex).Cells(hit.ColumnIndex)
iRowIndex = CInt(hit.RowIndex)
etc...

Set the Row.Selected property to True.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top