Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

Font Dialog component (control) in C# .net 2.0

Author: Zunnair
Download Source Code : 817_Font Dialog

: In this simple article you will learn that how to use Font Dialog component (control) in C# .net 2.0.

 Color dialog control is used to change the font (textbox, etc) on run time.

 Create new c# project. Drag Textbox, Font dialog control, and one button on the windows form.

Now write the following code on Form Load event:


private void LoadForm_Font(object sender, EventArgs e)


            this.Text = "devAsp Font Dialog Application";

            txtChange.Text = "";                   



Private Sub LoadForm_Font(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "devAsp Font Dialog Application"

        txtChange.Text = ""

    End Sub

Now write the following code on button click event:


private void btnChangeFont_Click(object sender, EventArgs e)


           DialogResult dR =  fntDialog.ShowDialog();


           if (dR == DialogResult.OK)


               txtChange.Font = fntDialog.Font;




Private Sub btnChangeFont_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim dR As DialogResult = fntDialog.ShowDialog()


        If dR = DialogResult.OK Then

            txtChange.Font = fntDialog.Font

        End If

    End Sub


When user will press change Font button font properties window willl open.


We are using DialogResult because we have to see what  user pressed. If user press ok than our program should apply changes but if user perss cancle than our program should do nothing.


This is the simple code for using font Dialog component (control).

Add Article Comment:
Name :
Email Address :
Comments :
<< Back” and”Forward” buttons of Web Browser Control using C# .net 2.0

Disclaimer - Privacy
© 2002-2017