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
close icon

FieldDescriptor set to null when Expression set??

I was wondering why this is happening? GridColumnDescriptor colDesc = grid.TableDescriptor.Columns["ColName"]; //colDesc.FieldDescriptor is not null here grid.TableDescriptor.ExpressionFields["ExpressionColumn"].Expression = "Value"; // FieldDescriptor is null here after 2nd line executes if (colDesc.FieldDescriptor.GetPropertyType() == Type.GetType("System.Boolean"))

2 Replies

AD Administrator Syncfusion Team June 14, 2006 11:58 PM UTC

The column descriptor collection is immutable meaning that when it is changes, a new insance of it needs to be created with the change. So, the old descriptor that you cached in a local variable was nulled out when the new collection was created as the result of modifying the expression. But if you access the descriptor directly from the collection, and not through a local variable, you will get the new instantiated descriptor for that column. So, this code shows none-null values in both places. GridColumnDescriptor colDesc = gridGroupingControl1.TableDescriptor.Columns["Col0"]; if(colDesc.FieldDescriptor != null) Console.WriteLine("not null A"); this.gridGroupingControl1.TableDescriptor.ExpressionFields["Expression"].Expression = "=[Col2]"; colDesc = gridGroupingControl1.TableDescriptor.Columns["Col0"]; if(colDesc.FieldDescriptor != null) Console.WriteLine("not null B");


MN Martin Nitschke June 15, 2006 05:12 PM UTC

Great, thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon