This is a migrated thread and some comments may be shown as answers.

Add Column with Delete Button Via Code

1 Answer 281 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brian Thomas
Top achievements
Rank 1
Brian Thomas asked on 13 Oct 2009, 06:29 PM
How do I add a custom column to my grid that contains a delete button?

I've found only one example of this but it's for the older version of the grid where the new one contains a data template in the grid column and/or a visual tree. I cannot figure out how to add a button into the data template.

grdCol =

new Telerik.Windows.Controls.GridViewColumn() { Name = "grdColDelete" };

 

DataTemplate dt =

new DataTemplate();

 

Button

 

btnDel = new Button(){Content = "Del", Width = 18, Height = 18, CommandParameter = new Binding("ApplicationCommands.Delete")};

 


//How do I get the btn into the data template??????????????????????????????

grdCol.CellTemplate = dt;

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 15 Oct 2009, 07:17 AM
Hi Brian Thomas,

The proper way to do this would be to inherit from the GridViewColumn class and override the CreateCellElement method. There you can return any kind of UIElement that you want, which in your case will be your delete button. Please, try this and let me know if it does not help.

Greetings,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Brian Thomas
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or