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

Modifying a cell programmatically

4 Answers 196 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 11 Feb 2013, 02:57 PM
Hi,

I've looked into this a good bit and can find nothing relevant.  Any threads touching on the subject are old and the API has since changed.  Basically I need to get access to an individual cell so that I can set a style for it.  I would expect there to be easy access to cells in the same way that columns can be accessed.

I'm looking for something like: 

myGrid.Columns[0].Rows[0].Style = myStyle;

A call like that would give me access to the top left cell of the grid.

Is there any way to do something like this?

Thanks,
Austin

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Feb 2013, 03:06 PM
Hello Austin,

Since the virtualization of RadGridView is turned on by default, it is not recommended to work with the visual elements (i.e. GridViewCell) and their properties. You would better work with the underlined data elements. Please refer to our online documentation for a reference. 
If you would like to style the cells then I would recommend you to check this help article on using a CellStyleSelector. Do you think you could apply that approch?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Austin
Top achievements
Rank 1
answered on 11 Feb 2013, 03:51 PM
Hi Didie,

Thank you for the quick response.  Unfortunately I don't think the CellStyleSelector will work for our purposes.  We do not know the structure of the class that is in our VirtualQueryableCollectionView until runtime so we don't have the luxury of hard-coding CellStyleSelectors into xaml etc.

Could you elaborate on what you mean by, "You would better work with the underlined data elements."  Recently, I worked extensively with the UI and data virtualization in order to meet our needs and I haven't seen anything in that documentation related to solving this sort of problem.
0
Austin
Top achievements
Rank 1
answered on 11 Feb 2013, 07:13 PM
By chance is there something like this on the WPF side of things?

http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html

If I could attach to an event that deals with cell formatting I could insert my own custom styling logic.  So far I haven't been able to find a suitable event for the WPF RadGridView.
0
Dimitrina
Telerik team
answered on 12 Feb 2013, 02:02 PM
Hello,

What I meant by "You would better work with the underlying data elements." is that if your ItemsSource is a collection of YourObject objects, then you should work with the YourObject business object associated with a particular cell/row.

You can still acess the Cells for the GridViewRow using the ChildrenOfType extension method, but please note that this will return only the visible cells if you use the UI Virtualization that is available by default. To get all the cells, then you should disable the virtualization (setting EnableRowVirualization="False" and EnableColumnVirtualization="False" as explained in the help article). Then you could get all the cells and work with the individual Cell to assign a Style for it. I hope this will work for you better.
 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Austin
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Austin
Top achievements
Rank 1
Share this question
or