Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataqgridview select white space in row

Status
Not open for further replies.

EagleTempest

Technical User
Jun 15, 2004
125
CA
VB .Net 2005 and Framework 2.0

I have the selection property set to:
.SelectionMode = DataGridViewSelectionMode.FullRowSelect

It appears that for the property:
datagridview..SelectedRows(0).Index to return the selected row, the user must actual click on the text in one of the cells of the row.

Selected a row by clicking on the white space in a cell changed the selected row visually on screen, but the Index property doesn't change (as tested by displaying the index in a textbox).

Any ideas to fix this that clicking anywhere on a row triggers the Index property?


 
gonna have to dispute that...

just tried it and it worked.
Code:
        If DataGridView1.SelectedRows().Count > 0 Then
            TextBox1.Text = DataGridView1.SelectedRows(0).Index
        End If

-The answer to your problem may not be the answer to your question.
 
I have noticed that the datagridview_CellContentClick event only triggers when the text in a cell is actually clicked on. Clicking on the white space doesn't cause the trigger.
 
i loaded a cell with no data, and it worked.

-The answer to your problem may not be the answer to your question.
 
Oops. I was using the CellContentClick method instead of CellClick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top