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

[Solved] Change column style of radGridView in silverlight

2 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
pawan
Top achievements
Rank 1
pawan asked on 11 Nov 2010, 07:53 AM
Hi

How we can change the coulmn style of radGridView in following points
1) when we drag and drop the column
2) when we provide three button, one button for style1 of first column , other for style2 of second column


Suppose we have one radGridView and it contains four column (column1, column2, column3, column4) and we have 5 rows.
We have two button.

When we click on first button, it will change the first column let say red background of first column through style
When we click on second button, it will change the second column let say blue background of second column through style

Above scenario is not working, but when we click on header of any column, it will modify column.


Pawan

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 16 Nov 2010, 04:40 PM
Hi Pawan,


You can change the background color of a column very quickly through setting its Background property to the color you want to use. You also have an option to change the background of your RadGridView columns through setting ColumnBackground property of RadGridView to an appropriate color.
Considering your first question can you clarify that you want to change column's background when you perform grouping in your RadGridView? It is essentially to know that GridViewColumns are not visual objects, as you said something happens when you sort a column, but actually you are operating on each GridViewCell contained in this column.

I have prepared an example for you that demonstrates a couple of approaches that you can use.


Please see the attached project and let me know if you need any further assistance.

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
0
pawan
Top achievements
Rank 1
answered on 17 Nov 2010, 07:29 AM

thanks Vanya 

i am unable to run your code. (reason: unrecognized version )

i just modified your code to run in my system.

but again same problem coming as we discussed .
when we click on button it do not chnage the background color of the column but when we click again on header for sorting., it will change the color of columns.

I am using silverlight 3



<

 

UserControl x:Class="SLTest.telerik.RadGridViewtest2"

 

 

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

 

 

Width="400" Height="300">

 

 

 

<Grid x:Name="LayoutRoot" Background="White" >

 

 

 

<Grid.RowDefinitions>

 

 

 

<RowDefinition/>

 

 

 

<RowDefinition/>

 

 

 

</Grid.RowDefinitions>

 

 

 

<telerik:RadGridView x:Name="radGridView1" AutoGenerateColumns="True">

 

 

 

</telerik:RadGridView>

 

 

 

<StackPanel Grid.Row="1" Orientation="Horizontal" Height="50">

 

 

 

<Button x:Name="btn1" Content="Set ColumnBackground" Click="btn1_Click"/>

 

 

 

</StackPanel>

 

 

 

</Grid>

 

</

 

UserControl>

 



cs file

using

 

System.Windows;

 

using

 

System.Windows.Controls;

 

using

 

System.Windows.Media;

 

namespace

 

SLTest.telerik

 

{

 

public partial class RadGridViewtest2 : UserControl

 

{

 

static public ItemCollection Items = new ItemCollection();

 

 

public RadGridViewtest2()

 

{

InitializeComponent();

LoadItems();

 

this.radGridView1.ItemsSource = Items;

 

}

 

private void LoadItems()

 

{

Items.Add(

new Item("1", "Item 1", "Item1 1"));

 

Items.Add(

new Item("2", "Item 2", "Item1 2"));

 

Items.Add(

new Item("3", "Item 3", "Item1 3"));

 

}

 

private void btn1_Click(object sender, RoutedEventArgs e)

 

{

 

this.radGridView1.Columns[0].Background = new SolidColorBrush(Colors.Red);

 

 

this.radGridView1.Columns[1].Background = new SolidColorBrush(Colors.Orange);

 

}

 

}

}



Tags
GridView
Asked by
pawan
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
pawan
Top achievements
Rank 1
Share this question
or