This tutorial will show you how to change font(Font Name, Font Size, Font Color) in Textbox or Label using font dialog. I use one Label and one Textbox to store the text and use two difference Buttons with Click_Event to generate code.
No | Control Type | Name | Text | Event |
1 | Form1 | FormChangeFont | Change Font | |
2 | Label1 | LabeFont | I Love Visual Studio - Label | |
3 | Textbox1 | TextboxFont | I Love Visual Studio - Textbox | |
4 | Button1 | ButtonLabelFont | Label Font | Click |
5 | Button2 | ButtonTextboxFont | Textbox Font | Click |
- As you see in the images to set font on Label, you just click on button"Label Font" or if you want to change font in Textbox, you just click on button"Textbox Font", it will pop up the font dialog for you to customize font(name; color; size or style).
Code
Public Class FormChangeFont
Private Sub ButtonLabelFont_Click(sender As Object, e As EventArgs) Handles
ButtonLabelFont.Click
FontDialog1.ShowDialog()
LabelFont.Font = FontDialog1.Font
End Sub
Private Sub ButtonTextBoxFont_Click(sender As Object, e As EventArgs) Handles
ButtonTextBoxFont.Click
FontDialog1.ShowDialog()
TextBoxFont.Font = FontDialog1.Font
End Sub
End Class
0 comments:
Post a Comment