Reflection

G

Guest

Hi,

In order to display multiple lines in a column, i am creating creating a new
column style deriving from the DataGridTextBoxColumn. To get the height of
each row i am using the following code in one of the methods of this custom
columnstyle class.

MethodInfo mi = t.GetMethod("get_DataGridRows",BindingFlags.FlattenHierarchy
| BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic |
BindingFlags.Public | BindingFlags.Static);
DataGrid dg = this.DataGridTableStyle.DataGrid;
Array dgRowArray = (Array)(mi.Invoke(dg,null));
Heights = new ArrayList();
foreach (object dgRowHeight in dgRowArray)
{
if (dgRowHeight.ToString().EndsWith("DataGridRelationshipRow") == true)
{
Heights.Add(dgRowHeight);
}
}

The above code works perfectly if use this column style in
System.Windows.Forms.DataGrid control.

I am also creating a custom datagrid deriving from the
System.Windows.Forms.DataGrid class .

If i use the above code in the custom DataGrid class, the

MethodInfo mi = t.GetMethod("get_DataGridRows",BindingFlags.FlattenHierarchy
| BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic |
BindingFlags.Public | BindingFlags.Static);

statement returns null. Is it not possible to obtain the method information
of a base class??

Thanks for the help.

Magesh
 
M

Marvin Varela

Yes it is

MethodInfo mi =
t.BaseType.GetMethod("get_DataGridRows",BindingFlags.FlattenHierarchy
| BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic
|
BindingFlags.Public | BindingFlags.Static);

this should return what you need.
 
G

Guest

Thanks a lot Marvin.

Magesh

Marvin Varela said:
Yes it is

MethodInfo mi =
t.BaseType.GetMethod("get_DataGridRows",BindingFlags.FlattenHierarchy
| BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic
|
BindingFlags.Public | BindingFlags.Static);

this should return what you need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top