[VB.NET] Datagrid scrollbar
Bonjour,
J'ai créé un petit datagrid, je gère l'auto dimensionnement de mes lignes grâce à cette classe :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Imports System
Imports System.Reflection
Public Class DataGridRowHeightSetter
Private dg As DataGrid
Private rowObjects As ArrayList
Public Sub New(ByVal dg As DataGrid)
Me.dg = dg
InitHeights()
End Sub
Private Sub InitHeights()
Dim mi As MethodInfo = dg.GetType().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.dg, Nothing), System.Array)
rowObjects = New ArrayList
Dim dgrr As Object
For Each dgrr In dgra
If dgrr.ToString().EndsWith("DataGridRelationshipRow") = True Then
rowObjects.Add(dgrr)
End If
Next dgrr
End Sub
Default Public Property Item(ByVal row As Integer) As Integer
Get
Try
Dim pi As PropertyInfo = rowObjects(row).GetType().GetProperty("Height")
Return 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
End Class |
Cela marche bien excepté l'absence de scrollbar Vertical lorsque je depasse la taille de mon datagrid :arf:
:merci: