Hello,
Toujours occupé avec ma création de usercontrol, je veux lui faire une jolie bordure histoire qu'il ressemble à quelque chose.
J'ai donc ce code dans son event Paint :
Avec ce code, j'ai bien les bordures supérieures et gauches mais pas les autres (basses et droites donc).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Private Sub EmptySlot_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint 'drawing borders 'top e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(0, 0), New Drawing.Point(Width, 0)) 'bottom e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(0, Height), New Drawing.Point(Width, Height)) 'left e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(0, 0), New Drawing.Point(0, Height)) 'right e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(Width, 0), New Drawing.Point(Width, Height)) 'drawing text if any If Text IsNot Nothing Then e.Graphics.DrawString(Text, New Drawing.Font(Drawing.FontFamily.GenericSansSerif, 8), Drawing.Brushes.Black, ClientRectangle) End If End Sub
Si je modifie le code comme ce qui suit, j'ai bien toutes les bordures :
Seulement avec ce code, si je mets 2 de mes usercontrols côte-à-côte, ça me fait une grosse bordure au milieu et c'est moche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Private Sub EmptySlot_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint 'drawing borders 'top e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(0, 0), New Drawing.Point(Width, 0)) 'bottom e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(0, Height - 1), New Drawing.Point(Width, Height - 1)) 'left e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(0, 0), New Drawing.Point(0, Height)) 'right e.Graphics.DrawLine(Drawing.Pens.LightSlateGray, New Drawing.Point(Width - 1, 0), New Drawing.Point(Width - 1, Height)) 'drawing text if any If Text IsNot Nothing Then e.Graphics.DrawString(Text, New Drawing.Font(Drawing.FontFamily.GenericSansSerif, 8), Drawing.Brushes.Black, ClientRectangle) End If End Sub.
Même problème si, à place de dessiner les bordures une à une, j'utilise ControlPaint.DrawBorder comme ceci :
J'ai l'intuition qu'il n'y a pas vraiment de solution vu que les controles ne se chevauche pas, je vais la bordure de l'un et, juste à côté, la bordure de l'autre...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Drawing.Color.LightSlateGray, ButtonBorderStyle.Solid)
Comment feriez-vous ?








.
Répondre avec citation
Partager