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

autosize the rowheights for a derived datagrid?

This question relates to WINDOWS FAQ QUESTION IN DataGrid control seciton How can I autosize the rowheights in my datagrid? while the code there works perfectely with the Datagrid control from System.Windows.Forms.DataGrid class , It does not wrok with the derived grid class, which inherits from datagrid class. What happens is this: In the next lines, cdgDataGrid refers to a System.Windows.Forms.DataGrid inherited control: objMethodInfo = cdgDataGrid.GetType().GetMethod( "get_DataGridRows", BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); The problem is, that it works fine when this code works over the control, but fails on the same call to the inherited control: as soon as I try to build a control based on this code, the variable objMethodInfo remains empty after this call. Any clue as to why this is happening

1 Reply

MA Manish June 11, 2004 01:24 PM UTC

And also what is the solution. One of the solutions mentioned in another post to use datagrid's GetCellBounds(row,col).height method without reflection does not seem to wrok for me. Has anybody soluiton to this ? > This question relates to WINDOWS FAQ QUESTION IN DataGrid control seciton > > How can I autosize the rowheights in my datagrid? > > while the code there works perfectely with the Datagrid control from System.Windows.Forms.DataGrid class , It does not wrok with the derived grid class, which inherits from datagrid class. > > What happens is this: > > In the next lines, cdgDataGrid refers to a System.Windows.Forms.DataGrid inherited control: > > objMethodInfo = cdgDataGrid.GetType().GetMethod( "get_DataGridRows", > BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase | BindingFlags.Instance > | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); > > The problem is, that it works fine when this code works over the control, but fails on the same call to the inherited control: as soon as I try to build a control based on this code, the variable objMethodInfo remains empty after this call. > > Any clue as to why this is happening > > >

Loader.
Live Chat Icon For mobile
Up arrow icon