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

Programmatically change selected row in masterview

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

Not Ranked
Posts 6
AmosWittenberg Posted: Fri, May 16 2008 6:58 AM

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 

Not Ranked
Posts 6

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