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

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

    Hello,

     

    I have a grid the user will enter data into, and while they are doing so I want to display what they type in a text box that has a larger font.  Is there a way for me to get the text the user has currently typed while the cell is still in edit mode?  I can get the value after they have gone to the next form, but not as they type.

     

    I hope that is clear, thanks for your help. 

    Imported from legacy forums. Posted by Arthur (had 596 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    Excellent, it works.  Thanks a lot for your help.

    Imported from legacy forums. Posted by Arthur (had 1015 views)

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