How to select a full row in datagrid?

A

AA

Do anyone know how to select a full row in datagrid instead of a particular
cell?

Whenever user click on a cell, I want to whole row to be selected.

I tried to code that in the cellColumnChange event programmatically that
highlighying the row of the cell.
However, it is strange that the cell will still be hightlighy in differenet
style of the row.

Any idea?

Thx in advance!
 
O

One Handed Man \( OHM - Terry Burns \)

Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp

Dim dg As DataGrid = DirectCast(sender, DataGrid)
Dim ht As DataGrid.HitTestInfo
ht = dg.HitTest(e.X, e.Y)
dg.Select(ht.Row)


End Sub

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
G

Guest

the other way may work, but doesnt for me as "dg.Select(ht.Row)" is read only
and cannot assign the row selected to any variable and you dont know which
row you selected. i modified it to this "i = ht.Row" and can read which row i
have.

Dim i As Integer
'commented out - datagrid created in design time
'Dim dg As DataGrid = DirectCast(sender, DataGrid)
Dim ht As DataGrid.HitTestInfo
ht = dg.HitTest(e.X, e.Y)
'commented out - dg.select is read only.
'dg.Select(ht.Row)
' i is the row number to use as see fit
i = ht.Row

hope that helps,
lee holsenbeck
 
O

One Handed Man \( OHM - Terry Burns \)

What are you talking about ? ' ReadOnly' this is a method which accepts an
argument and selects the row. ht.Row iny returns the index It does work, I
have tested it

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 

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