Thanks to "Imran Koradia" :
Here's code that works to get and set rowheights in derived DataGrids. Note
the function to get the rowobjects and get/set property is all within the
derived DataGrid Class called mydatagrid. The RowObject array of rows is
updated by calling get_RowObjects whenever the datasource changes or a row is
changed with the mouse:
Public Class mydatagrid
Private RowObjects as Arraylist = new Arraylist
'Call this whenever datasource changes or row height changed by mouse
Private Function get_RowObjects() As ArrayList
Dim rows As ArrayList = New ArrayList
Dim a As Type = Me.GetType
Dim b As Type = a.BaseType
Dim mi As MethodInfo = b.GetMethod("get_DataGridRows",
BindingFlags.FlattenHierarchy Or BindingFlags.IgnoreCase Or
BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public Or
BindingFlags.Static)
Dim dgra As System.Array = CType(mi.Invoke(Me, Nothing), System.Array)
Dim dgrr As Object
For Each dgrr In dgra
If dgrr.ToString().EndsWith("DataGridRelationshipRow" ) = True Then
rows.Add(dgrr)
End If
Next dgrr
Return rows
End Function 'get_RowHeights
'Use this Property to set or get rowheights
Public Property RowHeight(ByVal row As Integer) As Integer
Get
Try
Dim pi As PropertyInfo =
rowObjects(row).GetType().GetProperty("Height")
Return CInt(Fix(pi.GetValue(rowObjects(row), Nothing)))
Catch
Throw New ArgumentException("invalid row index")
End Try
End Get
Set(ByVal Value As Integer)
Try
Dim pi As PropertyInfo =
rowObjects(row).GetType().GetProperty("Height")
pi.SetValue(rowObjects(row), Value, Nothing)
Catch
Throw New ArgumentException("invalid row index")
End Try
End Set
End Property
Thanks a lot for helping me.
"Ken Tucker [MVP]" wrote:
Hi,
I converted the grid in the article dragging and dropping datagrid
columns to vb.net. Noticed get_Datagridsrows method doesnt work until the
grid had drawn itself.
Ken
-----------------
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridrows" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!
--
Dennis in Houston