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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Cell Control in Grid Designer

Thread ID:





8325 Oct 31,2003 05:03 PM UTC Dec 2,2003 09:42 AM UTC WinForms 6
Tags: GridControl
Desis Machino
Asked On October 31, 2003 05:03 PM UTC

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?

Administrator [Syncfusion]
Replied On 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

Desis Machino
Replied On 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?

Administrator [Syncfusion]
Replied On 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.

Desis Machino
Replied On 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.

Administrator [Syncfusion]
Replied On 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...

Administrator [Syncfusion]
Replied On December 2, 2003 09:42 AM UTC

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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon