Home Forums WinForms controls Xceed Grid for WinForms Get the value of a cell while in edit mode? Reply To: Get the value of a cell while in edit mode?

User (Old forums)
Member
Post count: 23064

Yes, this is possible.  The way to do it will depend on the editor being use for the column in which you want to do it.  For example, use the TextChanged event for a WinTextBox editor. Note that you need to subscribe to WinTextBox 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.:

   private void Form1_Load(object sender, System.EventArgs e)

   {

 

     gridControl1.Columns[ “City” ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager_ActivatingControl);

     gridControl1.Columns[ “City” ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler( CellEditorManager_DeactivatingControl );

   }

   private void CellEditorManager_ActivatingControl(object sender, CellEditorEventArgs e)

   {

     ( ( WinTextBox )e.Control ).TextBoxArea.TextChanged += new EventHandler( TextBoxArea_TextChanged );

   }

   private void CellEditorManager_DeactivatingControl( object sender, CellEditorEventArgs e )

   {

     //need to unsubscribe every time the editor is deactivated, if not, the subscriptions will kept pilling up!

     ( ( WinTextBox )e.Control ).TextBoxArea.TextChanged -= new EventHandler( TextBoxArea_TextChanged );

   }

   private void TextBoxArea_TextChanged( object sender, EventArgs e )

   {

     System.Diagnostics.Debug.WriteLine( ( ( TextBoxArea ) sender).Text);

   }

 

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