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

Programatic Styling For Specific Cells?

3 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 2
Steve asked on 28 Apr 2011, 11:05 PM

I have a Silverlight RadGridView that represents six months of the year.  Each row of data in the grid is stored as a record in an SQL table.

I want to allow users to attach a Note to a cell in the grid by right-clicking a cell and using a context menu to New | Edit | Delete a Note.  Each cell in the grid could have a Note associated with it…but most likely only a few Notes will get attached to the grid.

I need to be able to visually identify cells that have a Note associated with them.  I was thinking of applying  a background to cells that have notes (similar to Microsoft Excel’s use of a red tag in the upper right corner of the cell).  The Notes are stored in a separate SQL table and are tagged with the date that corresponds to the cell.

I have been able to set the background for specific columns:

 

                        //Sets the whole column

                        participantExerciseDetailsRadGridView.Columns[col].Background = new SolidColorBrush(Colors.Orange);

 

How do I go about setting the background color of specific cells (programmatically)?  I am already using a Conditional Style Selector to identify cells in Columns 29, 30, & 31 that are not valid dates and setting the ‘IsEnabled’ property to true | false.  I thought about creating another conditional style selector, but it appears that I cannot have multiple conditional style selectors on the same column.

 

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 29 Apr 2011, 11:55 AM
Hi Steve Dentel,

Yes, you are right. A column can have only one StyleSelector set, but the StyleSelector itself may operate with multiple styles and apply them regarding multiple conditions. So it is possible to have a StyleSelector that applies a style that modifies cells' background when a condition is fulfilled and another style, when another condition is fulfilled. For more extensive information, please refer to this article.

Kind regards,
Ivan Ivanov
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
Steve
Top achievements
Rank 2
answered on 29 Apr 2011, 07:37 PM
Thanks for the article on style selectors.  Do you have a VS2010 solution that you can provide that will help me understand this?

From my first post, I asked if there was a way to select a cell and style it.  Is it possible to do this without using style selectors as I was able to do for the entire row?

Thanks,

Steve
0
Ivan Ivanov
Telerik team
answered on 02 May 2011, 09:09 AM
Hi Steve Dentel,

I have prepared a sample project for you that utilizes a StyleSelector with multiple conditions. Please, refer to it and inform us if this approach meets your requirements.

Kind regards,
Ivan Ivanov
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
Steve
Top achievements
Rank 2
Answers by
Ivan Ivanov
Telerik team
Steve
Top achievements
Rank 2
Share this question
or