Problems with DataGridView

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
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top