We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Selection of text in current cell

Hello, I am using the following code in my GDBG so that when cell validation fails, it will display an error message and then highlight all the text in the current cell. It works fine if the user tries to tab or enter out of the cell, but if the user clicks on another cell, the message is displayed, however the text does not get highlighted. I tried playing with the "focus" method but haven''t had any luck yet. Suggestions? Private Sub m_grid_ValidateFailed(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridValidateFailedEventArgs) Handles m_grid.ValidateFailed Dim cc As GridCurrentCell = m_grid.CurrentCell cc.ErrorMessage = "Invalid value for " & m_grid.GridBoundColumns(cc.ColIndex - 1).HeaderText Dim tb As GridTextBoxControl = CType(cc.Renderer.Control, GridTextBoxControl) tb.SelectAll() e.Handled = True End Sub

1 Reply

AD Administrator Syncfusion Team May 21, 2005 12:10 AM UTC

Probably what is happening is that the text is selected immediately in your code, an dthen this gets undone when the error message is displayed later. Something to try. Instead of setting cc.ErrorMessage = "Invalid value for " & m_grid.GridBoundColumns(cc.ColIndex - 1).HeaderText go ahead and do a MessageBox.Show to display the message in your ValiedateFailed handler, then do the code that selects the text.

Loader.
Live Chat Icon For mobile
Up arrow icon