Adding button to some cells in GridViewTextBox

1 Answer 16 Views
GridView
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Toby asked on 18 Sep 2025, 11:38 AM | edited on 18 Sep 2025, 11:50 AM

Hi,

What is the best approach to adding a simple button to some cells (not all) in a grid view text box column? My column is read only and contains html text. I should also add that the button should overlay any text that might appear underneath it... So cell cannot contain stacked or docked sub elements.

I simply want to be able to show and handle a button at the top right hand corner of the cell. This cell is only added based on a some other algorithm in my code.

 

I thought aboutusing ButtonRenderer in a CellPaint but the text and button outline appear in 2 different places, so it seems that ButtonRenderer does not consider e.Graphics suplied to cell paint!

Any ideas?
Cheers
Toby

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 22 Sep 2025, 01:34 PM

Hi Toby,

Thank you for reaching out to us.

In general, adding custom elements to a cell is possible by creating a custom cell. A sample approach is demonstrated in the Creating custom cells help article. The tricky part of your requirement is that the button needs to be visible for specific cells. You can add the button to each cell. Then, in the SetContentCore() method, depending on your condition, you can hide or show the button.  

The custom cell is a way to add a button. You can draw the button on the cell using the Paint method, but that will require custom logic. This logic must handle several scenarios, like sorting, editing, grouping, and more. That is why I would suggest using the approach with the custom cell.

Regards,
Dinko | 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
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or