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

GridViewColumn using an UserControl, is that possible?

2 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 30 Sep 2010, 06:56 PM
I need to set an usercontrol which I've developed in the place of GridView column. For example, for a GridViewTextBoxColumn I coded something like this:
GridViewTextBoxColumn columnName = new GridViewTextBoxColumn();
columnName.HeaderText = "Phone";
columnName.Width = 120;

But now, I'd like to create an GridViewColumn as my UserControl type, something like:
GridViewMyUserControlColumn columnName= new GridViewMyUserControlColumn();
columnName.HeaderText = "Phone";
columnName.Width = 120;

I know that sentence is incorrect but I need to know how I can to set my user control as a GridView column, well, in case of that is possible... Thank you.

2 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 30 Sep 2010, 07:36 PM
Hello Antonio,

I don't know exactly what you mean but i'm guessing you need a custom cell element for the grid ( you can create a custom column for the grid, but a custom cell would be enough in most of the cases , at least in my oppinion.)

For this, there are a couple of KB articles you could follow, for example this KB article. It demonstrates how to handle radio buttons in RadGridView. using a custom column, for this article i've made some suggestions and additions, here(http://www.telerik.com/community/forums/winforms/gridview/toggle-state-of-radiobuttons-in-radgridviewcolumn.aspx) (sorry hyperlink manager down...) , also at the end of this post it is specified how to define a custom column.

This help article describes how to access and modify cell values. I hope this helps.

Hope this helps, if you have any more questions please do not hesitate to say so,

Best Regards,
Emanuel Varga
0
Julian Benkov
Telerik team
answered on 05 Oct 2010, 05:01 PM
Hello Antonio,

The approach of hosting a UserControl in a cell is not the best way to put components in a cell and it actually can bring additional issues and complexity. To avoid the possible issues, you should insert only RadElements in a custom CellElement. For additional information, please refer to the following article: Creating a RadRadioButtonCellElement. You can also view the forum thread given by Emanuel. 

I hope you find this information useful.

Regards,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Antonio
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or