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

RadGridView getting header cell

1 Answer 608 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mikhail
Top achievements
Rank 1
Mikhail asked on 12 Feb 2018, 02:51 AM

Hi!

I have RadGridView, and I need to get Header cell for all columns. How to get header cells (not content) in RadGridView.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Feb 2018, 02:00 PM
Hi Mikhail,

To get all the column headers you can first subscribe to the Loaded event of your RadGridView. Then using ChildrenOfType<T>() extension method you can get all GridViewHeaderCell. Keep in mind that you need to use Dispatcher. Check the following code snippet.
private void grid_Loaded(object sender, RoutedEventArgs e)
{
    this.Dispatcher.BeginInvoke(new Action(() => this.GetHeaders()));
}
 
private void GetHeaders()
{
    foreach (var headerCell in this.myGrid.ChildrenOfType<GridViewHeaderCell>())
    {
        // your code
    }
}

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Mikhail
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or