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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Strange Behavior in custom GridComboBoxCellRenderer

Thread ID:





60791 May 11,2007 02:22 PM UTC May 12,2007 12:54 AM UTC WinForms 3
Tags: GridControl
Asked On May 11, 2007 02:22 PM UTC


we have investigated a strange behavior in the GGC. Attached is a simple example which helps to explain the issue (it is just a fast dirty hack).

So our GGC is bound to a business object which implements IBindingList. Furthermore we have implemented a custom cell renderer to handle our custom objects. We use the OnValidate method of the derived GridComboBoxCellRenderer. Now when you start the attached example, directly click in the append new line row, enter "5" (as numeric value) and press return. So as I understand the binding mechanism, the binding list adds a new object to its internal list implementation when you enter the value "5". Now when you press return the OnValidate method is called. So in this method we use the ControlValue or the CurrentStyle.CellValue to use the type definition for validation. The problem is, that both - the ControlValue and the CurrentStyle.CellValue contain a null reference. So how can I get the value. I know the ControlText property contains the string, but I need to get the underlyling object. The CurrentStyle.CellValueType contains the type information, but the CellValue itself is a null reference.

It would be nice if you could help us.



Administrator [Syncfusion]
Replied On May 11, 2007 05:09 PM UTC

One way around this problem is to cache the object in an renderer.OnInitialize override, and then use this cached object in OnValidate. OnInitialize is called when your renderer is initially activated for editing.

private MyObject currentObject = null;
protected override void OnInitialize(int rowIndex, int colIndex)
base.OnInitialize(rowIndex, colIndex);
currentObject = this.CurrentStyle.CellValue as MyObject;

protected override bool OnValidate()
return currentObject.Validate(TextBox.Text);

Replied On May 11, 2007 06:02 PM UTC

Hi Clay,

thanks for your suggestion, but the CurrentStyle.CellValue is a null reference too in the "append new line" row even for the OnInitialize method. When you start the attached example, click in the new line row cell of the column (this must be the first click) enter a numeric value and press return. Then the CellValue is a null reference in the OnInitialize method.


Administrator [Syncfusion]
Replied On May 12, 2007 12:54 AM UTC

Here is your sample back. I added some code to your derived BindingList class to override EndNew and AddNewCore. In the AddNewCore, the AddingNew event was raised. The Renderer was modified to listen to the AddingNew event so it could get a reference to the new MyRow object, and from that new object, the renderer could set the CellValue for the new object. The EndNew override was added to make sure the new object got added to the list.

The custom cell renderer has no knowledge of your custom object unless you add code that allows it to access the custom information. Letting the renderer listen to AddingNew gives it access to the new object which it can then work with to place in the style.CellValue.



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