We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom Cell Control in Grid Designer

If I have correctly created a custom control, is it possible for me to relect that control as one of the Cell Types shown in the drop down list in the Grid Designer GUI?

6 Replies

AD Administrator Syncfusion Team October 31, 2003 09:35 PM UTC

No, it's not possible. We have planned to add support for that in a future version. What you could do right now instead is derive from GridControl and in your derived controls constructor you call CellModels.Add Then users could manually type in the CellType. (But it will not appear in the dropdown list). Stefan

DM Desis Machino December 1, 2003 04:16 PM UTC

I have tried to do as you indicated above and created a custom control which inherits from a GridControl, however, when I try to add this custom control to my form, I get this error "Object reference not set to an instance of an object", and the object does not get added at all. Any ideas on what I may be doing wrong?

AD Administrator Syncfusion Team December 1, 2003 04:45 PM UTC

A custom cell control should be derived from a cell renderer class and cell model class. Such a control is not derived from GridControl. Are you deriving your custom control from these two classes as discussed in the \Syncfusion\Essential Suite\Grid\Samples\In Depth\DerivedCellControlTutorial? There are lots of samples of derived cell types, do a search on CellModels.Add in the Grid\Samples folder to bring up all the different custom cells shown in the samples.

DM Desis Machino December 1, 2003 05:49 PM UTC

I have correctly derived a custom CellRenderer and CellModel class, but I want a way for my developers to use this cell type without having to add this cell type model to the GridControl everytime they want to use it. The solution which was given to be before (second response above) was to derive GridControl and add that custom CellModel in the derived control constructor. This way my developers can simply add the derived control from the toolbox in the same way a normal GridControl is used.

AD Administrator Syncfusion Team December 1, 2003 11:24 PM UTC

Sorry for the misread. Instead of adding the new cell control in the constructor of your derived grid, override OnCellModelsChanged and add the control there.
public class MyGridControl : GridControl
	public MyGridControl(): base()

	protected override void OnCellModelsChanged(CollectionChangeEventArgs e)
		this.CellModels.Add("NewControl", new GridPushButtonCellModel(this.Model)); //just some new cell...

AD Administrator Syncfusion Team December 2, 2003 09:42 AM UTC

To avoid adding the control more than once, you can protect the Add statement with code like:

Live Chat Icon For mobile
Up arrow icon