winforms gridview RowBackColor and BestFit...

1 Answer 64 Views
GridView
arbam
Top achievements
Rank 1
Iron
arbam asked on 27 Jun 2022, 01:40 PM

After binding the data to GridView, the background color of a specific row was changed through row formatting.
But there are two problems.
First, I can only see the changed background color if I click on the row.
I want the background color of the row to remain changed by the cell value even if it is not focused.
Second, when I scroll, the changed color remains where the background color of the row has changed.

ex) 1step -> 3 row

                     1column

1row                 x                         >> backColor : red(changed)

2row                o                          >> backColor : white

3row                o                           >> backColor : white

 

>>>>> down scoll

                      1column

4row                o                            >>backColor : red ???

5row                o                             >>backColor : white

6row                x                             >>backColor : red(changed)

 

>>>>> up scroll

                      1column

1row                 x                         >> backColor : red(changed)

2row                o                          >> backColor : white

3row                o                           >> backColor : red??

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Jun 2022, 10:02 AM
Hello, Taeheon,

Please make sure that the RowElement.DrawFill property is set to true in the RowFormatting event in order to see the applied colors. Due to the UI virtualization in RadGridView, cell/row elements are created only for currently visible cells/rows and are being reused during operations like scrolling, filtering, grouping and so on. In order to prevent applying the formatting to other columns' cell/row elements (because of the cell/row reuse), all customization should be reset for the rest of the cell elements. 

I would recommend you to have a look at the following help article demonstrating how to properly use the RowFormatting event:
https://docs.telerik.com/devtools/winforms/controls/gridview/rows/formatting-rows 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

arbam
Top achievements
Rank 1
Iron
commented on 29 Jun 2022, 02:02 AM

>> "Due to the UI virtualization in RadGridView, cell/row elements are created only for currently visible cells/rows and are being reused during operations like scrolling, filtering, grouping and so on."

This answer made me curious.
I made the background color change only if the cell value is the value I want.
However, I didn't do the default value if it wasn't the value I wanted through the else syntax.
Is this the problem I didn't solve?

arbam
Top achievements
Rank 1
Iron
commented on 29 Jun 2022, 02:50 AM

i said default value is e.RowElement.ResetValue
Dess | Tech Support Engineer, Principal
Telerik team
commented on 29 Jun 2022, 12:19 PM

If you apply the desired color only to some of the row elements without resetting the style for the rest of the rows, it is expected that after scrolling, the applied color to be applied to undesired rows. That is why each "if" statement in the RowFormatting event should have its "else" clause for resetting the applied style settings as it is demonstrated in the previously referred help article.
Tags
GridView
Asked by
arbam
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or