Modifying a cell programmatically

5 posts, 0 answers
  1. Austin
    Austin avatar
    12 posts
    Member since:
    Aug 2012

    Posted 11 Feb 2013 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Feb 2013 Link to this post

    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.

  3. Austin
    Austin avatar
    12 posts
    Member since:
    Aug 2012

    Posted 11 Feb 2013 Link to this post

    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.
  4. Austin
    Austin avatar
    12 posts
    Member since:
    Aug 2012

    Posted 11 Feb 2013 Link to this post

    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.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Feb 2013 Link to this post

    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.

Back to Top