9 Answers, 1 is accepted
0
Hi Srini,
You can set properties of the row directly in the RowLoaded event.
If you want to use styles you should work with the RowStyle and AlternatingRowStyle of the grid. Something like this:
I hope this helps.
Kind regards,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can set properties of the row directly in the RowLoaded event.
If you want to use styles you should work with the RowStyle and AlternatingRowStyle of the grid. Something like this:
using System.Windows; |
using System.Windows.Controls; |
using System.Windows.Media; |
using Telerik.Windows.Controls.GridView; |
namespace TicketID_240045_CellBackgroundBaseOnAValue |
{ |
public partial class MainPage : UserControl |
{ |
public MainPage() |
{ |
this.InitializeComponent(); |
this.playersGrid.ItemsSource = Club.GetPlayers(); |
this.playersGrid.RowStyle = new Style(typeof(GridViewRow)); |
this.playersGrid.RowStyle.Setters.Add(new Setter(Control.BackgroundProperty |
, new SolidColorBrush(Colors.Yellow))); |
this.playersGrid.UseAlternateRowStyle = true; |
this.playersGrid.AlternateRowStyle = new Style(typeof(GridViewRow)); |
this.playersGrid.AlternateRowStyle.Setters.Add(new Setter(Control.BackgroundProperty |
, new SolidColorBrush(Colors.Green))); |
} |
private void OnRowLoaded(object sender, RowLoadedEventArgs e) |
{ |
if (e.Row is GridViewRow) |
{ |
e.Row.Foreground = new SolidColorBrush(Colors.Red); |
} |
} |
} |
} |
I hope this helps.
Kind regards,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Srini
Top achievements
Rank 1
answered on 11 Sep 2009, 01:15 PM
Thanks for your Prompt reply...
but how to restrict the mouseOver and Selected Color change.
but how to restrict the mouseOver and Selected Color change.
0
Hello Srini,
If you want to do such modifications you will have to restyle RadGridView in Expression Blend.
Here is the help topic that describes how to do that.
Sincerely yours,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
If you want to do such modifications you will have to restyle RadGridView in Expression Blend.
Here is the help topic that describes how to do that.
Sincerely yours,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Srini
Top achievements
Rank 1
answered on 11 Sep 2009, 01:25 PM
it is applying for the whole grid but i want it for particular row.
private void rgvTripHistory_RowLoaded(object sender, RowLoadedEventArgs e)
{
if (e.DataElement != null)
{
if (((CustomerTripHistoryBO)e.DataElement).Dispute)
{
e.Row.Cells[1].IsEnabled = false;
e.Row.Background = new SolidColorBrush(Color.FromArgb(255, 117, 213, 126));
}
else
{
I want these rows to be in Some Selected color as well It should not trigger for Mouse over and Selected
this.rgvTripHistory.RowStyle = new Style(typeof(GridViewRow));
this.rgvTripHistory.RowStyle.Setters.Add(new Setter(Control.BackgroundProperty
, new SolidColorBrush(Colors.Yellow)));
//this.rgvTripHistory.AlternateRowStyle = new Style(typeof(GridViewRow));
//this.rgvTripHistory.AlternateRowStyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Green)));
e.Row.Background = new SolidColorBrush(Colors.Red);
}
}
}
private void rgvTripHistory_RowLoaded(object sender, RowLoadedEventArgs e)
{
if (e.DataElement != null)
{
if (((CustomerTripHistoryBO)e.DataElement).Dispute)
{
e.Row.Cells[1].IsEnabled = false;
e.Row.Background = new SolidColorBrush(Color.FromArgb(255, 117, 213, 126));
}
else
{
I want these rows to be in Some Selected color as well It should not trigger for Mouse over and Selected
this.rgvTripHistory.RowStyle = new Style(typeof(GridViewRow));
this.rgvTripHistory.RowStyle.Setters.Add(new Setter(Control.BackgroundProperty
, new SolidColorBrush(Colors.Yellow)));
//this.rgvTripHistory.AlternateRowStyle = new Style(typeof(GridViewRow));
//this.rgvTripHistory.AlternateRowStyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Green)));
e.Row.Background = new SolidColorBrush(Colors.Red);
}
}
}
0
Hello Srini,
In this case you will need to do 2 things.
1. Style the grid like I said in my previous post. You will remove the MouseOver and Selected colors for the whole grid. Now you will have a grid without mouse over and selection effects.
2. Attach to the RowLoaded event, check the DataElement and directly set e.Row.Background to the appropriate color. Now you will have different rows in different color depending on their type and you will not have the selection and mouse over overriding there color.
I hope this helps.
Best wishes,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
In this case you will need to do 2 things.
1. Style the grid like I said in my previous post. You will remove the MouseOver and Selected colors for the whole grid. Now you will have a grid without mouse over and selection effects.
2. Attach to the RowLoaded event, check the DataElement and directly set e.Row.Background to the appropriate color. Now you will have different rows in different color depending on their type and you will not have the selection and mouse over overriding there color.
I hope this helps.
Best wishes,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Srini
Top achievements
Rank 1
answered on 11 Sep 2009, 01:59 PM
Thanks for ur effort. I have already Designed it in blend. Actually my requirment is i have some Checked CheckBox rows which i should show in selected color remaing grid rows should behave normally like what i designd in blend, for that i have added a UserControl:Resource now everthing is working fine but, When i try to Mouse over or select the Checked row it is behaving like a default telerik grid color.
This is what i did
private void rgvTripHistory_RowLoaded(object sender, RowLoadedEventArgs e)
{
if (e.DataElement != null)
{
if (((CustomerTripHistoryBO)e.DataElement).Dispute)
{
e.Row.Cells[1].IsEnabled = false;
e.Row.Background = new SolidColorBrush(Color.FromArgb(255, 117, 213, 126));
//Here Mouse Over and select Color behave default. So either i want to change the MouseOver and Selected color OR i want to //restrict it.
}
else
{
e.Row.Style = (Style)this.Resources["GridViewRowStyle1"];
}
}
}
This is what i did
private void rgvTripHistory_RowLoaded(object sender, RowLoadedEventArgs e)
{
if (e.DataElement != null)
{
if (((CustomerTripHistoryBO)e.DataElement).Dispute)
{
e.Row.Cells[1].IsEnabled = false;
e.Row.Background = new SolidColorBrush(Color.FromArgb(255, 117, 213, 126));
//Here Mouse Over and select Color behave default. So either i want to change the MouseOver and Selected color OR i want to //restrict it.
}
else
{
e.Row.Style = (Style)this.Resources["GridViewRowStyle1"];
}
}
}
0
Hi Srini,
Can you please send us a small sample project that demonstrates what you have done.
We will do our best to come up with a workaround, but I do not think that disabling the mouse over and selection visual states for certain rows only would be possible.
Sincerely yours,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Can you please send us a small sample project that demonstrates what you have done.
We will do our best to come up with a workaround, but I do not think that disabling the mouse over and selection visual states for certain rows only would be possible.
Sincerely yours,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kristopher
Top achievements
Rank 1
answered on 31 Mar 2011, 09:45 AM
Hello,
How can i change the selected row color on expand command?
How can i change the selected row color on expand command?
0
Hello Kristopher,
I have prepared an example that describes a possible approach to your case. Of course you can just set the Background property, instead of applying a style, but utilizing this approach will enable you to reach a higher level of customization.
Greetings,
Ivan Ivanov
the Telerik team
I have prepared an example that describes a possible approach to your case. Of course you can just set the Background property, instead of applying a style, but utilizing this approach will enable you to reach a higher level of customization.
Greetings,
Ivan Ivanov
the Telerik team