Design Time Issues With User Controls

AdamEavy

New member
Joined
Mar 30, 2005
Messages
1
Programming Experience
1-3
Hi, first off thanks for reading.
I am trying to create my own various controls that will have shape effects etc etc. and have stumbled on the first hurdle.

I can successfully paint the border of the control and fill its inner area with the required background color however, when in design mode, when I resize my control, it leaves the previous border behind and does not update.

The painting itself is orking fine, because when I run it in a test app, it appears exactly as it is supposed to - its only during design time that it wont.

Not sure if any1 will be able to help, but heres my code so far: (The part in red is the main part I am having the issue with!)

Private Sub Label_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

e.Graphics.Clear(
Me.BackColor)

With e.Graphics

Select Case Me.Shape

Case LabelStyle.Normal

Select Case Me.DrawStyle

Case PaintStyle.Solid

Dim GP As New GraphicsPath(FillMode.Alternate)

GP.StartFigure()

GP.AddRectangle(
New Rectangle(BorderSize, BorderSize, Me.Width - BorderSize, Me.Height - BorderSize))

GP.CloseFigure()

Me.Region = New Region(GP)

.DrawRectangle(
New Pen(BorderColor, BorderSize), e.ClipRectangle)

GP.Dispose()

e.Dispose()

Case PaintStyle.Gradient

Case PaintStyle.Texture

End Select

'<<<<<<<<<<<<<<<>>>>>>>>>>>>

Case LabelStyle.RoundedSides

Select Case Me.DrawStyle

Case PaintStyle.Solid

Case PaintStyle.Gradient

Case PaintStyle.Texture

End Select

'<<<<<<<<<<<<<<<>>>>>>>>>>>>

Case LabelStyle.SmoothCornerCut

Select Case Me.DrawStyle

Case PaintStyle.Solid

Case PaintStyle.Gradient

Case PaintStyle.Texture

End Select

End Select

End With

End Sub

Thanks in advance for any support - it is much appreciated since I am new to GDI+ and control authoring.
 
i'm new to GDI development as well

you could try using Me.Refresh at the end of your resize event
 
Hi you could try this.

Open the collapsed region tha is written by the designer and just after the ' Add any initialization' statement input this code.

setstyle(resize/redraw,true)

That should solve your problem however like you, i'm quite new to all this aswell.
 
Back
Top