Advertisement
calfred2808

How To Put Text Into A PictureBox

Jul 20th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.98 KB | None | 0 0
  1. 'https://www.youtube.com/watch?v=4SbhYg_iwKk
  2.  
  3. Public Class Form1
  4. Dim Graph As Graphics
  5. Dim Drawbitmap As Bitmap
  6. Dim Brush As New Drawing.SolidBrush(Color.Black)
  7.  
  8. RichTextBox1_TextChanged:
  9. Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
  10. Graph = Graphics.FromImage(Drawbitmap)
  11. PictureBox1.Image = Drawbitmap
  12. Graph.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  13. Graph.DrawString(RichTextBox1.Text, RichTextBox1.Font, Brush, PictureBox1.Location)
  14.  
  15. Font:
  16. Dim dlg As New FontDialog
  17. If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
  18. RichTextBox1.Font = dlg.Font
  19. End If
  20.  
  21. Colour:
  22. Dim dlg As New ColorDialog
  23. If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
  24. Brush.Color = dlg.Color
  25. RichTextBox1.ForeColor = dlg.Color
  26. End If
  27.  
  28. You can add save code, if ya want the codes for save, here it is:
  29.  
  30. Dim dlg As New SaveFileDialog
  31. dlg.Filter = "Bitmap|*.bmp"
  32. If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
  33. PictureBox1.Image.Save(dlg.FileName)
  34. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement