Hide Telerik GridView Column Filter By Column Type or Name winforms

This is for Winforms. I don’t know about the other technologies.

Sure you can iterate through the columns and manually disable each…  But the tools are already in place.

To hide column filters by Image column types:

void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
 if (e.CellElement is Telerik.WinControls.UI.GridFilterCellElement)
 {
  // disable column filter by column type
  if (e.CellElement.ColumnInfo is Telerik.WinControls.UI.GridViewHyperlinkColumn)
   e.CellElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
  }
}

 

To hide column filters by header name…or is this column name

void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
   if (e.CellElement is Telerik.WinControls.UI.GridFilterCellElement)
   {
    // disable column filter by header name
    if (e.CellElement.ColumnInfo.FieldName == "ColumnHeaderNameHere")
     e.CellElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
   }
}

Leave a Reply