DataGrid CurrentCellChanged

L

Lester Moreno

Hello all,

I'm trying to find a way to get a event raised when you change some text on
a DataGrid Cell, I need to be able to search in another table what the user
typed on that cell.

I found this, but this only give me the row and the cell I change position
to.

[C#]
// Create an instance of the 'CurrentCellChanged' EventHandler.
private void CallCurrentCellChanged()
{
myDataGrid.CurrentCellChanged += new EventHandler(Grid_CurCellChange);
}

// Raise the event when focus on DataGrid cell changes.
protected void Grid_CurCellChange(object sender, EventArgs e)
{
// String variable used to show message.
string myString = "CurrentCellChanged event raised, cell focus is at ";
// Get the co-ordinates of the focussed cell.
string myPoint = myDataGrid.CurrentCell.ColumnNumber + "," +
myDataGrid.CurrentCell.RowNumber;
// Create the alert message.
myString = myString + "(" + myPoint + ")";
// Show Co-ordinates when CurrentCellChanged event is raised.
MessageBox.Show(myString, "Current cell co-ordinates");
}


Anyone know?

Thanks
 
S

sandman

The Validating event might work for you. It gets fired
before the cell is actually exited. It has the added
advantage that you can cancel out and display an error
message if you don't find what you are looking for.
 

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