G
gfexrd
Hi,
I am having problems refreshing current cell, with DataViewGrid that
is bound with a DataTable.
I am doing CellValidating, and try to change the value of cell that I
am doing validating data.
But I can change value of a different cell, but I can not see the
change on same cell when CellValidanting method exits.
Then if I put the focus on this cell again I exit, HERE I can see the
change.
What am I doing wrong?
Thanks in advance.
************************************************************************
DataTable newOrder = new DataTable("NewOrderToLoad");
DataColumn codePart = new DataColumn("Code");
DataColumn descriptionPart = new DataColumn("Description");
dataGridView1.DataSource = newOrder;
private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "Code")
{
if (e.FormattedValue.ToString().Trim() == "")
{
dataGridView1.Rows[e.RowIndex].ErrorText = "Invalid !!!";
e.Cancel = true;
}
string tmpStr =
myODBC.checkCodeAndFormatting(e.FormattedValue.ToString());
if (tmpStr == null)
{
dataGridView1.Rows[e.RowIndex].ErrorText = "Not exist
Code !!!";
e.Cancel = true;
}
else
{
dataGridView1.CurrentRow.Cells[0].Value = "DO NOT
MODIFY"; // HERE I AM PUTTING
//
RETURN CODE, BUT NOTHING
//
HAPPEND
dataGridView1.CurrentRow.Cells[1].Value = "DO
MODIFY"; // HERE I CAN MODIFY ANYTHING
}
}
}
I am having problems refreshing current cell, with DataViewGrid that
is bound with a DataTable.
I am doing CellValidating, and try to change the value of cell that I
am doing validating data.
But I can change value of a different cell, but I can not see the
change on same cell when CellValidanting method exits.
Then if I put the focus on this cell again I exit, HERE I can see the
change.
What am I doing wrong?
Thanks in advance.
************************************************************************
DataTable newOrder = new DataTable("NewOrderToLoad");
DataColumn codePart = new DataColumn("Code");
DataColumn descriptionPart = new DataColumn("Description");
dataGridView1.DataSource = newOrder;
private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "Code")
{
if (e.FormattedValue.ToString().Trim() == "")
{
dataGridView1.Rows[e.RowIndex].ErrorText = "Invalid !!!";
e.Cancel = true;
}
string tmpStr =
myODBC.checkCodeAndFormatting(e.FormattedValue.ToString());
if (tmpStr == null)
{
dataGridView1.Rows[e.RowIndex].ErrorText = "Not exist
Code !!!";
e.Cancel = true;
}
else
{
dataGridView1.CurrentRow.Cells[0].Value = "DO NOT
MODIFY"; // HERE I AM PUTTING
//
RETURN CODE, BUT NOTHING
//
HAPPEND
dataGridView1.CurrentRow.Cells[1].Value = "DO
MODIFY"; // HERE I CAN MODIFY ANYTHING
}
}
}