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

Essential Grid and Reflection

Hello. Does someone know how can I access to Essential Grid's and Columns' properties via PropertyInfo.GetValue, SetValue. I have following code: PropertyInfo oProperty=null; oProperty=EssColumn.StyleInfo.GetType().GetProperty("CellAppearance") if (oProperty.CanRead) { object oValue = oProperty.GetValue(EssColumn.StyleInfo,null); - here I get exception "'System.Reflection.TargetInvocationException' occurred in mscorlib.dll" } However following works without exception: oProperty.SetValue(EssColumn.StyleInfo,SomeValue,null); Thanks to anybody who can help.

2 Replies

AD Administrator Syncfusion Team August 19, 2003 09:15 AM

> Hello. Does someone know how can I access to Essential Grid's and Columns' properties via PropertyInfo.GetValue, SetValue. > I have following code: > PropertyInfo oProperty=null; > oProperty=EssColumn.StyleInfo.GetType().GetProperty("CellAppearance") > if (oProperty.CanRead) > { > object oValue = oProperty.GetValue(EssColumn.StyleInfo,null); - here I get exception "'System.Reflection.TargetInvocationException' occurred in mscorlib.dll" > } > However following works without exception: > oProperty.SetValue(EssColumn.StyleInfo,SomeValue,null); > > Thanks to anybody who can help. Hi Dmitry, I modified the samples\databound\gdbdmultiheader sample in order to reproduce the problem. I added using System.Reflection; and I added the following lines at the end of Form1_Load: PropertyInfo pi = this.gridBinder.InternalColumns[0].StyleInfo.GetType().GetProperty("CellAppearance"); object ob = pi.GetValue(this.gridBinder.InternalColumns[0].StyleInfo, null); Trace.WriteLine(ob); That seems to work fine. Can you tell me what you are doing different? Thanks, Stefan


AD Administrator Syncfusion Team August 20, 2003 09:41 PM

The main problem is that I create GrigColumn with System.Activator. In this way I cannot access it via InternalColumns. But this is not critical. I discovered that when Activator creates new object of GridColumn some fields are undefined, and this causes exception when I try to read such a field. I think this is a problem of .net itself not Syncfusion. Thank you.

Loader.
Live Chat Icon For mobile
Up arrow icon