Read all cell values from Radgridview WPF

2 Answers 45 Views
GridView
MuruganSilvers
Top achievements
Rank 1
MuruganSilvers asked on 14 Jul 2021, 01:55 PM | edited on 15 Jul 2021, 07:18 AM

I am using data table for populating data through Radgridview control instead of direct collection and facing some issue with this control which is not able to get all the cell value from this control. In my project is using through code behind.
Current Telerik version : v4. 0. 30319

Thanks & Regards

Murugansilvers

2 Answers, 1 is accepted

Sort by
1
Stenly
Telerik team
answered on 20 Jul 2021, 02:59 PM

Hello MuruganSilvers,

If I understand your issue correctly, you want to see the cells' background color updated based on a condition. To achieve the wanted behavior you could create a custom CellStyleSelector class. The following documentation contains detailed steps on how to create one:

WPF DataGrid | CellStyleSelector | Telerik UI for WPF

You could look at this documentation that explains the UI Virtualization and how we use it in the RadGridView control:

WPF DataGrid | UI Virtualization | Telerik UI for WPF

Another point to consider is that it is not recommended to work with the visual elements of RadGridView(GridViewCell, GridViewRow, etc.) directly, as in your case to alter their Background property. This may result in inconsistent behavior due to the containers' recycling mechanism such as the one you observe while scrolling. Instead, you should use the underlying data items as explained in the Style Selectors section.

Also, I am attaching an example project regarding the mentioned StyleSelector class for your reference.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

MuruganSilvers
Top achievements
Rank 1
commented on 26 Jul 2021, 01:34 PM

Hi Stenly

Thanks for your support. I applied style in codebehind now it's working.


Thanks & Regards
Murugan M
0
Stenly
Telerik team
answered on 16 Jul 2021, 12:14 PM

Hello MuruganSilvers,

The issue is that RadGridView uses UI virtualization which ensures that only the visible rows of a container are rendered on the screen.That is why you can't get all the cells from the control. You could still access them through the DataTable as follows:

var dataRows = this.MyDataTable.Rows;

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

MuruganSilvers
Top achievements
Rank 1
commented on 18 Jul 2021, 03:36 PM | edited

Hi Stenly

I understood the issue on Radgridview but I need to update the cell background color whenever scroll horizontal bar or vertical bar. If have any possible ways to achieve this, please help me out from this.

Thanks & Regards
Murugansilvers M
Stenly
Telerik team
commented on 19 Jul 2021, 01:18 PM

Hi MuruganSilvers, 

Could you please explain the wanted behavior a bit more? Also could you see the following documentation about styling cells based on certain conditions:

WPF DataGrid | CellStyleSelector | Telerik UI for WPF

MuruganSilvers
Top achievements
Rank 1
commented on 20 Jul 2021, 09:39 AM

Hi Stenly

I want change background color in Radgridview cell based on some condition, that's why I need to take all the cells then only update background color. I didn't use direction collection and using grouping in Rradgridview control. How to update background color in Radgridview cell whenever scrolling horizontal and vertical bar.

Thanks & Regards
Murugansilvers M
Tags
GridView
Asked by
MuruganSilvers
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or