private void bSource_PositionChanged(object sender, EventArgs e) { bSource.EndEdit(); // if the user moves to a new row, check if the last row was changed BindingSource thisBindingSource = (BindingSource)sender; DataRow ThisDataRow = ((DataRowView)thisBindingSource.Current).Row; // <- This is where it breaks if (ThisDataRow == LastDataRow) { // we need to avoid writing a datarow to the database when it is still processing. Otherwise // we get a problem with the event handling of the DataTable. return; } UpdateRowToDatabase(); // track the current row for next PositionChanged event LastDataRow = ThisDataRow; } /* Example for two of the context menu buttons */ private void toolStripMenu_40hour_Click(object sender, EventArgs e) { bSource.Filter = "colHours = 40"; } private void toolStripMenu_Overtime_Click(object sender, EventArgs e) { bSource.Filter = "colHours = 0 OR colHours > 40"; } private void toolStripMenu_Reset_Click(object sender, EventArgs e) { bSource.RemoveFilter(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)