Grid concepts - I'm missing something...

W

WineNCheese

I have a DataGrid that is bound to a datatable, which has a sort specified
on the default view. When rows are added programatically to the datatable,
they are displayed at the end of the grid via the magic of databinding.
However, the rows (including the new one) seem to be in sort order in the
default view of the DataTable. If the rows are in sort order in the
dataview, and not in sort order in the grid, how does databinding work? (I
can imagine implementations, but they make me want to hit something) Even
more important, how can I make this magic work for me?

I want to:

1. Find and select the row that was added, using the sort key of the default
view. 'Find' does not work once rows have been added, because they are no
longer in the correct sort order.

2. Programmatically sort the grid based on runtime criteria. I'm not sure
this is possible with this grid.

3. Iterate through the rows of the grid to find something. This does not
seem possible, and I cannot use the bound dataview since there is a
disconnect based on the additions and user sorts.

Is it just me, or is this control not worth 0.02?

WNC
 
W

WineNCheese

Oh, and the Refresh method on the CurrencyManager doesn't seem to do
anything useful either.
 
W

WineNCheese

OK, I'll answer my own questions...

After much experimentaion, it appears I cannot use the defaultView of the
table to which I bound for find operations. The magic is that the currency
manager seems to maintain its own view. So, if I get the view from the
currency manager as such:

DataView dv = (DataView)cm.List;

and apply a sort and find on it:

dv.Sort = "mysortcolumn"
int index = dv.Find( searchValue );

I can now select the new row by:

cm.Position = index;

I guess now that I think about it, it makes sense. I'm going to have to
experiment with making my own views and see how that affects things when I
have more time...

Productivity inching up...

WNC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top