Datagrid autoresize -- from reflection
I've created a user control inherited from DataGrid which resizes each cell for its content to be readable upon resizing.
The solution is (I get advised from another Windows Forms- Forum Q & A ) to rely on Reflection to get a reference to hidden method providing the number of data rows in the grid.
In the next lines, cdgDataGrid refers to a System.Windows.Forms.DataGrid inherited control:
Imports System.Refelction
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 ( Windows form datagrid iteself ), but fails on the same call to the inherited control ( my inherited datagrid ): as soon as I try to build a control based on this code, the variable objMethodInfo remains empty after this call.
Any advice or Solution ??