CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006
    Posts
    94

    Question Datagrid: Selecting a cell will automatically select the row

    If my datagrid has several columns and the user selects a cell in one of those columns, is there a way for it to select the whole row and not just the selected cell? I'm sure there is a way to test which cell was selected, then from that data, you can make the row selected. The question is how?

  2. #2
    Join Date
    Sep 2002
    Location
    Mumbai
    Posts
    98

    Re: Datagrid: Selecting a cell will automatically select the row

    In mouse upe event of the grid u can write

    Dim pt As Point = New Point(e.X, e.Y)
    Dim hti As DataGrid.HitTestInfo = dgSuppliesRecords.HitTest(pt)
    If hti.Type = DataGrid.HitTestType.Cell Then
    DataGridName.CurrentCell = New DataGridCell(hti.Row, hti.Column)
    DataGridName.Select(hti.Row)
    End If

    HTH

  3. #3
    Join Date
    Mar 2006
    Posts
    94

    Re: Datagrid: Selecting a cell will automatically select the row

    Thank you that worked beautifully. All I had to do was fill in the function:

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

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

Featured