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

set column bold in code

1 Answer 558 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Silvan
Top achievements
Rank 1
Silvan asked on 24 May 2011, 08:41 AM
I want set a column to be the font bold in the program-code (not in xaml).

How can i do this?

1 Answer, 1 is accepted

Sort by
1
Vanya Pavlova
Telerik team
answered on 24 May 2011, 09:03 AM
Hello Marcel,

 

You may access any column in RadGridView either by index or by given its UniqueName. Afterwards you may apply the corresponding CellStyle,as shown below:

MainPage.xaml

<Window.Resources>
        <Style x:Key="style1" TargetType="{x:Type telerik:GridViewCell}">
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>
    </Window.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="Last Name"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="Last Name"/>
                <telerik:GridViewCheckBoxColumn EditorStyle="{StaticResource CheckBoxStyle}" DataMemberBinding="{Binding Married}" Header="Is Married"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

MainPage.xaml.cs

public MainWindow()
{
            // Required to initialize variables
            InitializeComponent();
            this.radGridView.ItemsSource = EmployeeService.GetEmployees();
            this.radGridView.Columns[0].CellStyle = this.Resources["style1"] as Style;
}

Best wishes,
Vanya Pavlova
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
Silvan
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or