datagrid.Select raises error...

S

SammyBar

Hi,

I'm trying to insert by code a new record to a datagrid control, and show
this new record. My datasource is an ArrayList. The code is the following:

i = is the position of the new ArrayList item
fCurrencyManager = (CurrencyManager)datagrid.BindingContext[theArrayList];
datagrid.DataSource = theArrayList;
fCurrencyManager.Position = i; // the grid will be pointing to i
datagrid.CurrentRowIndex = i;
datagrid.Select(i); // I want this new row to be highlighted

But the last line of code throws a System.Exception:Exception; message:
"Exception". If the i row was present since the grid was first populated,
this code works as expected.
What can be wrong?

I'm using VS2005 with emulator for PPC2003

Thanks in advance
Sammy
 
I

Ilya Tumanov [MS]

ArrayList does not have ListChanged event so DataGrid would never know
you've just added a row.

And of course you could not select row which is not in the grid from grid's
point of view.



Please consider using another data source which has ListChanged event (e.g.
BindingList), extend ArrayList with this event or rebind each time item is
added/changed/removed.


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

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