This is a migrated thread and some comments may be shown as answers.

Change background colour of FilteringRow

4 Answers 198 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sheraz Naseeb
Top achievements
Rank 1
Sheraz Naseeb asked on 13 Sep 2010, 11:57 AM
Hi Telerik Team,

Please advice if I can change the background colour of Filtering Row in RadGridView, if so then how can I do that. I just want to do that to make it stand out from other rows in the grid.

Many thanks,

Sheraz

4 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 14 Sep 2010, 02:52 PM
Hi, 

It's not obvious how to do this, but the easiest way I found was this: 

1: Create a private member to hold the GridViewFilteringRowInfo
Private m_FilteringRow As GridViewFilteringRowInfo

2: Handle the CreateRow event of the GridView
Private Sub RadGridView1_CreateRow(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCreateRowEventArgs) Handles RadGridView1.CreateRow
    If TypeOf e.RowInfo Is GridViewFilteringRowInfo Then
        m_FilteringRow = e.RowInfo
    End If
End Sub

In your Form_Load event add this at the end
Me.RadGridView1.TableElement.GetRowElement(m_FilteringRow).BackColor = Color.Black

The reason for setting the rowinfo to the private member is that the RowElement is null in the CreateRow event when you need it. 

Hope that helps
Richard
0
Sheraz Naseeb
Top achievements
Rank 1
answered on 15 Sep 2010, 10:53 AM
Hi Richard,

Thanks for your reply but I had already found the solution for this my code is...

Private Sub RadGridView1_ViewCellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
 
        If TypeOf e.CellElement Is Telerik.WinControls.UI.GridFilterCellElement Then
            DirectCast(e.CellElement.RowInfo, Telerik.WinControls.UI.GridViewFilteringRowInfo).Height = 28
            e.CellElement.DrawFill = True
            e.CellElement.NumberOfColors = 1
            e.CellElement.BackColor = Color.Beige
            e.CellElement.Font = New Font("Verdana", 10)
        End If
 
    End Sub

I also tried your code but I guess the version I am working with does not support .TableElement.

Thanks...
0
Richard Slade
Top achievements
Rank 2
answered on 15 Sep 2010, 10:57 AM
Hi, 

I think your solution is better and I can confirm it works under the latest release (2010 Q2 - Build 806) as well. 
Cheers
Richard
0
Alexander
Telerik team
answered on 16 Sep 2010, 04:52 PM
Hello,

You can define the background color of the FilteringRow from the theme or in runtime.

You can edit the theme using Visual Style Builder (you can find more information about this tool here). To set the background color in runtime you can use the ViewCellFormatting event as in the Sheraz's solution. Additional information about the RadGridView CellFormatting events could be found in this help article.

I hope it helps.

Regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Sheraz Naseeb
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Sheraz Naseeb
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or