Datagrid custom columnstyle problem
-
Hi, I've got a problem with my custum datagridcolumnstyles. As soon as I sort on a column with a custom column style after I have selected a different row, the code redraws a label(which is the columnstyle in the attached code snippet) the size of the entire grid. Also when changing the readonly status of the datagrid the datagrid seems to "freeze". I am probably missing something, but I am not sure what. Any suggestions? The attached code is converted from C# to vb so there might be some error there. Thanks David Public Class clDTRDataGridLabelColumn Inherits DataGridColumnStyle Private lb As New Label ' The isEditing field tracks whether or not the user is ' editing data with the hosted control. Private isEditing As Boolean Public Sub New() lb.Visible = False lb.Dock = DockStyle.Fill Me.NullText = "" 'tb.Height = 27 End Sub Protected Overrides Sub Abort(ByVal rowNum As Integer) isEditing = False RemoveHandler lb.TextChanged, _ AddressOf lbtextChanged Invalidate() End Sub Protected Overrides Function Commit _ (ByVal dataSource As CurrencyManager, ByVal rowNum As Integer) _ As Boolean lb.Bounds = Rectangle.Empty AddHandler lb.TextChanged, _ AddressOf lbtextChanged If Not isEditing Then Return True End If isEditing = False Invalidate() Return True End Function Protected Overloads Overrides Sub Edit( _ ByVal [source] As CurrencyManager, _ ByVal rowNum As Integer, _ ByVal bounds As Rectangle, _ ByVal [readOnly] As Boolean, _ ByVal instantText As String, _ ByVal cellIsVisible As Boolean) Dim value As String If cellIsVisible Then lb.Text = value lb.Visible = True AddHandler lb.TextChanged, _ AddressOf lbtextChanged Else lb.Text = value lb.Visible = False End If If lb.Visible Then DataGridTableStyle.DataGrid.Invalidate(bounds) End If End Sub Protected Overrides Function GetPreferredSize( _ ByVal g As Graphics, _ ByVal value As Object) As Size Return New Size(100, lb.PreferredHeight) End Function Protected Overrides Function GetMinimumHeight() As Integer Return lb.PreferredHeight End Function Protected Overrides Function GetPrefe