Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15103 |

    Have tried using the event but nothing is ever returned is there some other way you are supposed to be doing this?

    I need this event for a user accepting a record like you do on most lists/grids

    Imported from legacy forums. Posted by Zon (had 1697 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m not totally sure I understand your request correctly. I assume you want the user to be able to edit the values within a cell, and be notified when he has finish editing. Normally, you need to subscribe to the cell EditLeft or the row EditEnded to do this :

    e.g.:

    private void Form1_Load(object sender, System.EventArgs e)
    {
    foreach( Cell cell in dataRowTemplate1.Cells )
    {
    cell.EditLeft += new EditLeftEventHandler(cell_EditLeft);
    }
    //or
    dataRowTemplate1.EditEnded += new EventHandler(dataRowTemplate1_EditEnded);
    }

    private void cell_EditLeft(object sender, EditLeftEventArgs e)
    {
    System.Diagnostics.Debug.WriteLine( ( ( Cell )sender).Value.ToString() );
    }

    private void dataRowTemplate1_EditEnded(object sender, EventArgs e)
    {
    System.Diagnostics.Debug.WriteLine( ( ( CellRow )sender).Cells[ 0 ].Value.ToString() );
    }

    However, if you want to access the editor which is used in the cell while it is being edited, you need to subscribe to TextBox events through the ActivatingControl event of the CellEditorManager. This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.

    e.g.:

    //at Form_Load

    private void Form1_Load(object sender, System.EventArgs e)
    {
    gridControl1.Columns[ 0 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager0_ActivatingControl);
    gridControl1.Columns[ 0 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager0_DeactivatingControl);

    //Event handlers

    private void CellEditorManager0_ActivatingControl(object sender, CellEditorEventArgs e)
    {
    ( ( WinTextBox )e.Control).TextBoxArea.DoubleClick += new EventHandler(TextBoxArea_DoubleClick);
    }

    private void CellEditorManager0_DeactivatingControl(object sender, CellEditorEventArgs e)
    {
    //need to unsubscribe, if not, the subscriptions will kept pilling up!
    ( ( WinTextBox )e.Control).TextBoxArea.DoubleClick -= new EventHandler(TextBoxArea_DoubleClick);
    }

    private void TextBoxArea_DoubleClick(object sender, EventArgs e)
    {
    System.Diagnostics.Debug.WriteLine( sender.ToString() );
    }

    Imported from legacy forums. Posted by André (had 2892 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.