By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,868 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,868 IT Pros & Developers. It's quick & easy.

DataGrid CurrentCellChanged

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
-----Original Message-----
Hello all,

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

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

[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
.

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.