ARTICLE

How to use Font Dialog in VB.Net on runtime?

Posted by Hirendra Sisodiya Articles | Visual Basic 2010 July 15, 2010
This article shows that how to use font dialog in VB.NET.
Download Files:
 
Reader Level:

HTML clipboarWe are very familiar with font dialog, we frequently use font dialog in various  text editor like word pad,MS word,Notepad etc. this is very  important for text managing and editing. net framework provides us strong Font Dialog class, through this we can also change the font size, pattern, style etc of text or selected text.

This article shows how to use fontdialog in vb.net application.i have already said that The FontDialog box is pretty familiar to anyone who has used a Windowsbased

word processor. The key point to remember is that its Font property returns

a Font object that you assign to a control or form's Font property.

 

Example code :  Assumes you have a Richtextbox named RichTextBox1 on your form,

Along with a button that uses the default name of btnFont:


FontDlg1.JPG
 

Code :

 

Private Sub btnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFont.Click

        Dim FontDlg As New FontDialog

        If FontDlg.ShowDialog = Windows.Forms.DialogResult.OK Then

            If RichTextBox1.SelectedText.Trim = "" Then

                RichTextBox1.Font = FontDlg.Font

            Else

                RichTextBox1.SelectionFont = FontDlg.Font

            End If

        End If

    End Sub

FontDlg2.JPG

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor