Found the following interesting discussion in the Newsgroups:
| save record in datagrid while still editing by:jaYPee | |
| i'm wondering how can i update the current record in datagrid while still editing the record. cause i have a checkbox in my datagrid and i want to save the record before changing the value of this checkbox to true to enforce referential integrity. i don't have problem changing the checkbox to true if the record/row in my datagrid is already save. the problem is that if it is the 1st time i add record to this datagrid and then update the checkbox to true. thanks in advance for any help. | |
| Reply: by:Cor Ligthert | |
| Hi jaYPee, You can look what currentcellchanged event from the datagrid (and than check in that the columnumber if it is the checkbox) and than the currencymanager.endcurrentedit can do for you. Not tested just an idea? Cor | |
| Reply: by:jaYPee | |
| thanks for the immediate reply. here's my code i used. it is working the 2nd time i click the checkbox again. but didn't work the 1st time i click the checkbox
| |
Posted by Xander Zelders

3 Comments:
Mate, sorry I can't help you with your problem, but you just solved mine: datagrid.endedit - you little ripper!
Best Regards,
Baraholka
You solved my problem too. I think maybe your first line, the "Nothing" should be something:
int _currentColumnIndex = DataGrid1.CurrentCell.ColumnNumber;
DataGridColumnStyle Nothing = DataGrid1.TableStyles[0].GridColumnStyles[_currentColumnIndex];
So, "Nothing" has become something.
DataGrid1.EndEdit(Nothing, DataGrid1.CurrentRowIndex, False);
DataGrid1.BindingContext[DataGrid1.DataSource,
DataGrid1.DataMember].EndCurrentEdit();
'save record first before adding course
SqlDataAdapter2.Update(DsStudentCourse1)
I had the same problem...for me, the solution was
DataGrid1.CurrentRowIndex = DataGrid1.CurrentRowIndex;
Kurt
Post a Comment
<< Home