in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Programmatically change selected row in masterview

Last post 05-16-2008 7:16 AM by AmosWittenberg. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-16-2008 6:58 AM

    Programmatically change selected row in masterview

    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 

    Filed under:
  • 05-16-2008 7:16 AM In reply to

    Re: Programmatically change selected row in masterview

    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)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.