Programmatically change selected row in masterview

WinForms

ComponentOne's WinForms controls

Programmatically change selected row in masterview

  • rated by 0 users
  • This post has 1 Reply |
  • 0 Followers
  • Hi

    I have: An ADO.NET typed dataset, A C1DataViewSet with a master DataView and a child DataView.  Then two grids, one bound to the DataViewSet with DataMember masterView. the other to the DataViewSet childView.  The grids are plain vanilla DatGridViews.

    I want to programmatically change the currently selected/active/current master row so that the child grid is updated with the child rows.

    I have tried row.Selected = true but that does not work.

    I am sure I am missing something obvious but what?

    Please help. 

    Amos Wittenberg 

  • Answering my own question for the benefit of others:

    grid.CurrentCell = row.Cells[0]  (or any other cell in the desired row)

    Background:

    I have a control - a very fancy treeview as it happens - that does NOT support databinding.  I want to leverage the considerable benefits of the C1DataExtender plumming.

    Solution:
    I made a UserControl with my fancy treeview and an invisible DataGridView bound to my DataViewSet.  On the DataBindingComplete event I read the rows of the grid to populate my fancy tree.  Conversely, on the NodeSelected event of the tree, I make the corresponding row in the grid current.

    Presto.  Almost no code.
    Hope this helps one or two people.

    Amos Wittenberg
     

Page 1 of 1 (2 items)