DataGrid EndEdit throws exception

G

Guest

I have a DataGrid loaded from a Database. The app works great until I add
code to save the cell the user is editing. I've broken up the code for easy
reading as follows:

int col = dataGrid.CurrentCell.ColumnNumber;
int row = dataGrid.CurrentCell.RowNumber;

// exception here:
DataGridColumnStyle dgc = dataGrid.TableStyles[0].GridColumnStyles[col];

catalogGrid.EndEdit(dgc, row, false);

The line bellow the comment throws a 'System.ArgumentOutOfRangeException'.
The datagrid is created before this code is called. The exception is thrown
by the TableStyles collection, not the GridColumnStyles. Somehow 0 is out of
range for the table styles, I don't get it... I will try some work arounds
but if anyone has any ideas, let me know.

Thanks,
Greg
 
G

Guest

Well apparently you need to manually add the TableStyles. No more
exceptions, but the data the user has entered is still not saved with both a
true and a false passed to EndEdit()... I really don't want to force users to
hit enter after the last edit to confirm the change is made when they save a
table.
 

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