When I run the custom control that contains me In the program, the column buttons are placed correctly. However, in the design, when I add or delete columns, the control does not update the added buttons.
They are normal at runtime, but When designing, I need to close the form and reopen it (force redrawing) to update the column buttons.
How to force redraw the user control programmatically?
Column properties are as follows:
_
_
_
_
Public ReadOnly Property Columns() As ListView.ColumnHeaderCollection
Get
Return ListView1.Columns
End Get
End Property
I tried to redraw like this Controls:
Me.Invalidate()
Dim x As New Rectangle With {.X = Me.Location.X, .Y = Me.Location.Y, .Size = Me.Size}
Me.NotifyInvalidate(x)
But for some reason, it doesn’t work. At design time, every time a column is added, the corresponding Button.
In the Sub for adding/removing columns, add the following:
Dim Graphics As Graphics = [yourform].CreateGra phics
Dim ParamArg As New PaintEventArgs(Graphics, [yourform].ClientRectangle)
InvokePaint(Me, ParamArgs)
Every time you add/remove, this will enforce annoying Thing.
I created a custom list view control. Every time I add a new column, I set it to add a new button.
When I When I run the program that contains my custom control, the column buttons are placed correctly. However, at design time, when I add or delete columns, the control does not update the added buttons.
They are in It is normal at runtime, but at design time I need to close the form and reopen it (force redrawing) to update the column buttons.
How to force the user control to be redrawn programmatically?
Column properties are as follows:
_
_
_
_
Public ReadOnly Property Columns() As ListView.ColumnHeaderCollection
Get
Return ListView1.Columns
End Get
End Property
I tried to redraw like this Controls:
Me.Invalidate()
Dim x As New Rectangle With {.X = Me.Location.X, .Y = Me.Location.Y, .Size = Me.Size}
Me.NotifyInvalidate(x)
But for some reason, it doesn’t work. At design time, every time a column is added, the corresponding Button.
It’s just a simple idea, may not be the best solution, but it doesn’t hurt to try, I guess it works, even if I Say, this is not the best way.
In the Sub used to add/remove columns, add the following:
Dim Graphics As Graphics = [yourform].CreateGraphics
Dim ParamArg As New PaintEventArgs(Graphics, [you rform].ClientRectangle)
InvokePaint(Me, ParamArgs)
Every time you add/remove, this will enforce annoying things.