goneWildCoder
Programmer
I am having some problems figuring out the following:
1) Updating database with changes to dataset on Form Closing
Here is my form closing method:
private void DivFrmClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
int i;
if (dataSet11.HasChanges())
i = dbUpdate(); // method to update table
...
}
Row of data gets updated only when a new row has been added(focus is lost from that row)!!
How do I get around this to accomodate update of a row even when focus is not lost from curretn row?
2) I am trying to enforce an input string of length 2 characters for the 1st column. I set the MaxLength property to 2 and also do a check for strings of length less than 2. If it is so, I throw an Error Message . THe Error Message gets thrown twice ( The Message is in no kind of loop)....Here is what I have -->
private void Division_ColumnChanging(object sender, System.Data.DataColumnChangeEventArgs e)
{
//Check for errors in the Div_Code column
if (e.Column.ColumnName.Equals("Div_Code"))
{
if (e.ProposedValue.ToString().Length != 2)
{
MessageBox.Show("Invalid entry: Division Code must be 2 characters", "SPIRIT2 - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// transfer control to cell
dataGrid1.CurrentCell = (DataGridCell) sender;
}
Please help!!
1) Updating database with changes to dataset on Form Closing
Here is my form closing method:
private void DivFrmClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
int i;
if (dataSet11.HasChanges())
i = dbUpdate(); // method to update table
...
}
Row of data gets updated only when a new row has been added(focus is lost from that row)!!
How do I get around this to accomodate update of a row even when focus is not lost from curretn row?
2) I am trying to enforce an input string of length 2 characters for the 1st column. I set the MaxLength property to 2 and also do a check for strings of length less than 2. If it is so, I throw an Error Message . THe Error Message gets thrown twice ( The Message is in no kind of loop)....Here is what I have -->
private void Division_ColumnChanging(object sender, System.Data.DataColumnChangeEventArgs e)
{
//Check for errors in the Div_Code column
if (e.Column.ColumnName.Equals("Div_Code"))
{
if (e.ProposedValue.ToString().Length != 2)
{
MessageBox.Show("Invalid entry: Division Code must be 2 characters", "SPIRIT2 - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// transfer control to cell
dataGrid1.CurrentCell = (DataGridCell) sender;
}
Please help!!