Hello..

i will try to be clear.. here i am working on a datagrid. in datagrid one column is editable as i am passing DataGridTextColumn to it and holding the data when users enter data into it and writing back to database. i am saving to database using datagrid_celleditending event also i am using the datagridcelleditendingeventargs to do this. This is done and working fine. i have added new functionality such that instead of entering data in datagrid, users will enter in one textbox which will be given on top of datagrid and the on entering data in to cell i am synchronizing it with datagrid cell and i can see data in it (just like excel having one big bar on top and you can write the data there and also see in datagrid). i am doing this by using textbox_keyup event. now i wanted to fire the event of datagrid_celleditending event args. i tried using routed event implementation but i am not sure whether it works here or not..

hope i am not confusing, please help..

Here is a chunk of code.

private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
    {
        DataRowView rowView = e.Row.Item as DataRowView;
        rowBeingEdited = rowView;
        //Here my logic to write to database will come
        .........
        .........      
   }

The above event is working fine when i change in datagrid now i wanted to fire this when i enter data in the text box which is not a part of datagrid

private void tb_Comments_KeyUp(object sender, KeyEventArgs e)
    {
        if (rowBeingEdited != null)
        {
            rowBeingEdited.Row["Comments"] = tb_Comments.Text;
           //here i wanted to go to the above event and fire it..how can i do it??
        }

     }

all u have to do is call the function ...

i.e. add this line ...

dataGrid_CellEditEnding(sender, e);

-----------------
and thats it, the funtion will be fired!

(mark as solved if solved)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.