Mettre du texte dans un picturebox - Windows Forms
Fri May 31 2024 15:45:29 GMT+0000 (Coordinated Universal Time)
Saved by
@demelevet
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
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Chargement de l'image
Me.PictureBox1.Image = System.Drawing.Bitmap.FromFile("C:\Documents and Settings\Ludo\Bureau\Video Club\Jacquettes\hardcandy.jpg")
'Définit un objet Graphics avec l'image de ton picturebox
Dim ObjGraphics As Graphics = Graphics.FromImage(Me.PictureBox1.Image)
'Définit le pinceau pour l'écriture
Dim brush As Brush = New SolidBrush(Color.Black)
'Définit la police d'écriture avec la taille ainsi que le style (gras, italique...)
Dim font As New Font("times new roman", 20, FontStyle.Bold)
'Dessine le texte sur l'image à la position X de 10 et Y de 10
ObjGraphics.DrawString(Me.TextBox1.Text, font, Brushes.Brown, 10, 10)
'Libère les ressources
ObjGraphics.Dispose()
'Redessine l'image avec le texte
Me.PictureBox1.Image = Me.PictureBox1.Image
End Sub
content_copyCOPY
https://www.developpez.net/forums/d320845/dotnet/developpement-windows/windows-forms/mettre-texte-picturebox/
Comments