Code Share: Hide Filter row text

2 posts, 0 answers
  1. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 14 Mar 2011 Link to this post

    If you don't like the way the RadGridView adds the Filter text (e.g. Contains, Equals, etc) in the Filter row, you can use this code that I wrote.  The text is unreadable in skinnier columns.  Plus, it confused my users since clicking on the word "Contains" did not automatically allow them to start typing; they had to click next to the word.

    Anyways, this code simply collapses the text element and adds a tooltip to the filter row's cell and button.
    Private Sub RadGridView1_ToolTipTextNeeded(ByVal sender As Object, ByVal e As Telerik.WinControls.ToolTipTextNeededEventArgs) Handles RadGridView1.ToolTipTextNeeded
        If TryCast(sender, GridFilterCellElement) IsNot Nothing Then
            e.ToolTipText = CType(sender, GridCellElement).ToolTipText
        End If
    End Sub
    Private Sub RadGridView1_ViewCellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
    End Sub
    Friend Sub HideFilterText(ByVal CellElement As GridCellElement)
        Dim oFilterCellElement As GridFilterCellElement
            If TryCast(CellElement, GridFilterCellElement) IsNot Nothing Then
                oFilterCellElement = CType(CellElement, GridFilterCellElement)
                oFilterCellElement.ToolTipText = oFilterCellElement.FilterOperatorText.Text.Replace(":", "")
                oFilterCellElement.FilterButton.ToolTipText = oFilterCellElement.FilterOperatorText.Text.Replace(":", "")
                oFilterCellElement.FilterOperatorText.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            End If
        Catch ex As Exception
            ' Do nothing
        End Try
    End Sub

    I now use this on all my grids within my current project.  It would be nice if something similar was built in.  If it is already, then I've missed it in the documentation.

    Feel free to offer code improvements or another way.
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 15 Mar 2011 Link to this post

    Hello Jason,

    Good work on this one, but the tooltip text will just reflect the default selection, if the user changes the filter operator, that change will not be applied to the tooltip.

    Keep up the good work

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. DevCraft R3 2016 release webinar banner
Back to Top