DataGrid CurrentCellChanged

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lester Moreno

    #1

    DataGrid CurrentCellChanged

    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 'CurrentCellCha nged' EventHandler.
    private void CallCurrentCell Changed()
    {
    myDataGrid.Curr entCellChanged += new EventHandler(Gr id_CurCellChang e);
    }

    // Raise the event when focus on DataGrid cell changes.
    protected void Grid_CurCellCha nge(object sender, EventArgs e)
    {
    // String variable used to show message.
    string myString = "CurrentCellCha nged event raised, cell focus is at ";
    // Get the co-ordinates of the focussed cell.
    string myPoint = myDataGrid.Curr entCell.ColumnN umber + "," +
    myDataGrid.Curr entCell.RowNumb er;
    // Create the alert message.
    myString = myString + "(" + myPoint + ")";
    // Show Co-ordinates when CurrentCellChan ged event is raised.
    MessageBox.Show (myString, "Current cell co-ordinates");
    }


    Anyone know?

    Thanks


  • sandman

    #2
    DataGrid CurrentCellChan ged

    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.
    [color=blue]
    >-----Original Message-----
    >Hello all,
    >
    >I'm trying to find a way to get a event raised when you[/color]
    change some text on[color=blue]
    >a DataGrid Cell, I need to be able to search in another[/color]
    table what the user[color=blue]
    >typed on that cell.
    >
    >I found this, but this only give me the row and the cell[/color]
    I change position[color=blue]
    >to.
    >
    >[C#]
    >// Create an instance of the 'CurrentCellCha nged'[/color]
    EventHandler.[color=blue]
    >private void CallCurrentCell Changed()
    >{
    > myDataGrid.Curr entCellChanged += new EventHandler[/color]
    (Grid_CurCellCh ange);[color=blue]
    >}
    >
    >// Raise the event when focus on DataGrid cell changes.
    >protected void Grid_CurCellCha nge(object sender,[/color]
    EventArgs e)[color=blue]
    >{
    > // String variable used to show message.
    > string myString = "CurrentCellCha nged event raised,[/color]
    cell focus is at ";[color=blue]
    > // Get the co-ordinates of the focussed cell.
    > string myPoint = myDataGrid.Curr entCell.ColumnN umber[/color]
    + "," +[color=blue]
    > myDataGrid.Curr entCell.RowNumb er;
    > // Create the alert message.
    > myString = myString + "(" + myPoint + ")";
    > // Show Co-ordinates when CurrentCellChan ged event is[/color]
    raised.[color=blue]
    > MessageBox.Show (myString, "Current cell co-ordinates");
    >}
    >
    >
    >Anyone know?
    >
    >Thanks
    >
    >
    >.
    >[/color]

    Comment

    Working...