Results 1 to 7 of 7

Thread: Highlighting datagrid row

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279

    Question Highlighting datagrid row

    How can I highlight an entire datagrid row by clicking anywhere in a row?

    I tried the following:

    DataGrid1.Select(DataGrid1.CurrentCell.RowNumber)

    In the CurrentCellChanged event but it changes the appearance of the selected cell. Any ideas?
    A cynic knows the price of everything but the value of nothing.

  2. #2
    New Member
    Join Date
    Feb 2004
    Location
    Bulgaria
    Posts
    12
    Hi

    Just study this with code example. can be in help

    http://www.dotnetbips.com/displayarticle.aspx?id=205


    brgds
    Krasimir

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279
    I put this in the MouseUp event:

    Dim pt = New Point(e.X, e.Y)
    Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt)

    If hti.Type = DataGrid.HitTestType.Cell Then
    DataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)
    DataGrid1.Select(hti.Row)
    End If
    A cynic knows the price of everything but the value of nothing.

  4. #4
    Lively Member Atte's Avatar
    Join Date
    Feb 2004
    Posts
    79
    Can also try this row in CurrentCellChanged event:

    DataGrid1.Select(DataGrid1.CurrentRowIndex)

  5. #5
    New Member vbxPuppet's Avatar
    Join Date
    Nov 2005
    Location
    alabama
    Posts
    14

    Re: Highlighting datagrid row

    http://www.freevbcode.com/ShowCode.asp?ID=5746

    this is a great sample code example of how to do this plus a few other little things that may be useful. works great out of the box, and was easy to add to a project with very little modding to get it to work.

    I found it and just thought it may help some others who need this too.
    This example is for use with a winform.
    Last edited by vbxPuppet; Nov 27th, 2005 at 02:20 PM.

  6. #6
    Lively Member Atte's Avatar
    Join Date
    Feb 2004
    Posts
    79

    Re: Highlighting datagrid row

    Looks good, thanks vbxPuppet. I got this solved for long ago, but it's a good example to anybody who needs it...

    As you are interested in Winforms Datagrids, maybe you know some handy way to apply "autocomplete" in Datagrid ComboBox - i.e. getting first matching result by typing the first letters...

    I know how to do it in normal ComboBox, but not in Datagrid... Would you have any good code sample for such of Class or any tips..?


    (Framework 1.1)

  7. #7
    New Member vbxPuppet's Avatar
    Join Date
    Nov 2005
    Location
    alabama
    Posts
    14

    Re: Highlighting datagrid row

    sorry but no,

    I also have now moved all my projects to 05, and framework 2.0
    the datagridview is worth the upgrade alone, plus all the other really kewl stuff they shoved up vs's ars ;>

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