Results 1 to 3 of 3

Thread: row select using datagrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    70

    row select using datagrid

    Hi everyone,

    I'm using a datagrid to display the name of customers and some details. Everytime I click on any of the fields it only selects that cell I've clicked on, instead of selecting the whole row just as it happens in any table in any windows program.

    Does anyone know how to change that??

    Thanks in advance

  2. #2
    Hyperactive Member Grunt's Avatar
    Join Date
    Oct 2004
    Location
    Las Vegas
    Posts
    499
    kinda a dirty fix, but it works:

    VB Code:
    1. Private Sub grdResults_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdResults.MouseUp
    2.  
    3.         'declare the vars
    4.         Dim pt As New Point(e.X, e.Y)
    5.         Dim hti As DataGrid.HitTestInfo = grdResults.HitTest(pt)
    6.  
    7.         'if type is cell, select row
    8.         If (hti.Type = DataGrid.HitTestType.Cell) Then
    9.             grdResults.CurrentCell = New DataGridCell(hti.Row, hti.Column)
    10.             grdResults.Select(hti.Row)
    11.         End If
    12.  
    13.     End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    70

    Resolved

    Alright thank you,

    What I'm actually doing now is different but I came to it thanks to you!

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

    grdResults.Select(grdResults.CurrentRowIndex)

    End Sub

    Thanks a lot you fixed my problem!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width