Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Raising Event

Status
Not open for further replies.

BDRichardson

Programmer
Jul 23, 2003
46
GB
Hi,

Is it possible to raise an event programmatically? The reason I ask is, when changing a DataRow within a DataTable, the RowState is not updated from Unchanged to Modified unless the focus moves from the current DataRow to another. I would like the RowState to be updated, i.e. raise the RowChanged (OnRowChanged) event after a Cell value has changed, as opposed to being raised by the focus being moved from one DataRow to another.
 
I use a combination of two tricks to accomplish this:

Code:
//Initialized elsewhere
DataGrid grd;
DataGridTableStyle tbl;

//This method is necessary because the second method
//does not work when switching tabs
grd.EndEdit(
   tbl.GridColumnStyles[grd.CurrentCell.ColumnNumber], 
   grd.CurrentRowIndex, false);

//Using the EndEdit method of the DataGrid alone is
//not good enough because it does not work for add rows
grd.CurrentRowIndex = grd.CurrentRowIndex;

You might be able to get away with just the second line if you don't have tabs in your app.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top