how to show html in GirdView and how to cancle default selection

1 Answer 42 Views
GridView
sun
Top achievements
Rank 1
Iron
sun asked on 29 Jan 2024, 09:01 AM

hello, i have use the approach from article https://docs.telerik.com/devtools/winforms/knowledge-base/display-and-edit-html-text-in-grid-cells to

show html in gridview ,but after set the datasource , the html style didn't display.  Just like the following image ,i have set the color to red use font element:

the second problem is that ,when the grid view render finished ,the first cell of the gridview is selected and the backgroud color is blue, when i set the second cell to selected , the first cell bgcolor not changed. the method clearSelection of the GridView cann't work,even though i called this method in constructor ,the first cell bgcolor is still blue.

thanks

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 31 Jan 2024, 02:06 PM

Hello, sun,

According to the provided information, it seems you follow the approach in the referred KB article and use html tags to set the text color in the cell to red. Note, in case you want to modify the look of how text is displayed in the cell I would recommend using formatting events: CellFormatting/ViewCellFormatting. These events are specially created for such cases when the client wants to change the styles of the cells in a grid. If your case requires just changing the cell text color to red you can simply set the e.CellElement.ForeColor property for a specified cell or all cells and the color will be applied to the cells. Can you please give the CellFormatting event a try and let me know if it is suitable for achieving your goal.

As to your second problem, by default the grid shows the first cell/row as selected when the grid is loaded. If you want to disble this behavior you can set set CurrentRow property of RadGridView to null. However, it would be strange if you select another cell and the first one does not change. Is it possible to demonstrate this problem in a sample runnable project since I am not able to reproduce it on my end? 

Please let me know if you have any further questions.

Regards,
Nadya | Tech Support Engineer
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.

Tags
GridView
Asked by
sun
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or