PC Review


Reply
Thread Tools Rate Thread

DataGrid EndEdit throws exception

 
 
=?Utf-8?B?R0JheWFyZA==?=
Guest
Posts: n/a
 
      18th Nov 2004
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R0JheWFyZA==?=
Guest
Posts: n/a
 
      18th Nov 2004
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.

"GBayard" wrote:

> 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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EndReceiveFrom throws exception. TN Microsoft C# .NET 1 19th Sep 2008 08:47 PM
BindingSource.EndEdit() throws Exception Aaron Microsoft ADO .NET 2 20th Jun 2008 02:01 PM
Attachments.Add throws Exception Ferdinand Zaubzer Microsoft Outlook Interoperability 7 20th Jun 2006 12:24 PM
PictureBox Bug, throws exception. =?Utf-8?B?Q2FtaWxvIFRlbGxlcw==?= Microsoft Dot NET Framework Forms 1 11th Apr 2004 10:52 PM
Proposed datarow values lost after exception in EndEdit Pascal Microsoft ADO .NET 0 6th Feb 2004 07:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 AM.