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.
Unfortunately, activation email could not send to your email. Please try again.

Programatically selecting some text in a cell

Thread ID:

Created:

Updated:

Platform:

Replies:

1133 Sep 25,2002 11:07 AM Sep 26,2002 12:55 AM Windows Forms 2
loading
Tags: GridControl
Roy Muller
Asked On September 25, 2002 11:07 AM

Greetings, I'd like to provide a text search function to search cell contents. The Cell Types are TextBox and are set to read-only. How can I select the matching subset of the text within a cell (as if the user highlighted it with the mouse)? On a related note, I found the grid.SetTopRow() method... is there a similar method to determine if a particular cell is visible? -Roy

Administrator [Syncfusion]
Replied On September 26, 2002 12:48 AM

> Greetings, > > I'd like to provide a text search function to search cell contents. The Cell Types are TextBox and are set to read-only. How can I select the matching subset of the text within a cell (as if the user highlighted it with the mouse)? > > On a related note, I found the grid.SetTopRow() method... is there a similar method to determine if a particular cell is visible? > > -Roy

Administrator [Syncfusion]
Replied On September 26, 2002 12:55 AM

Here is some code that will highlight the text in a cell. It makes sure the proper cell is active and being edited as this is the only way you can display selected text in a cell currently. Now if you want to simultaneously select text in several cells, that would require a custom cell control with you drawing the selection rectangle yourself within the cell. This code uses the standard selection process of the edit control which is only available for the currentcell.
Public Sub SelectCellText(ByVal row As Integer, ByVal col As Integer, ByVal selStart As Integer, ByVal selLength As Integer)
        Try
            Me.GridControl1.Focus()
            If Not Me.GridControl1.CurrentCell.HasCurrentCellAt(row, col) Then
                Me.GridControl1.CurrentCell.MoveTo(row, col, Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.SetFocus Or Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.ScrollInView, False)
            ElseIf Not Me.GridControl1.CurrentCell.IsEditing Then
                Me.GridControl1.CurrentCell.BeginEdit()
            End If

            Dim tb As GridTextBoxControl = CType(Me.GridControl1.CurrentCell.Renderer.Control, GridTextBoxControl)
            tb.SelectionLength = selLength
            tb.SelectionStart = selStart
        Catch

        End Try
    End Sub
To decide whether a cell is visible or not, you can use the methods GridControl.ViewLayout.IsColVisible and GridControl.ViewLayout.IsRowVisible.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;