Results 1 to 4 of 4

Thread: Change font style during run time

  1. #1
    prem_rajani's Avatar
    prem_rajani is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Jul 2005
    Location
    Coimbatore
    Posts
    22
    Reputation
    113

    Question Change font style during run time

    Hi,

    Please can any1 help me out with changing the font style of a label. I tried it but it says read only property.
    Prem

  2. #2
    ayozzhero's Avatar
    ayozzhero is offline VB.NET Forum Genius
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Apr 2005
    Location
    Malaysia
    Posts
    186
    Reputation
    147
    Hope this sample helps:
    Code:
    Dim FontName As String = "Arial"
    Dim FontSize As Integer = 14
    Dim FS As New Font(FontName, FontSize, FontStyle.Regular)
    Label1.Font = FS
    If what you really want is just the FontStyle, and not the whole font setting, you can just declare a variable as FontStyle only.

  3. #3
    prem_rajani's Avatar
    prem_rajani is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Jul 2005
    Location
    Coimbatore
    Posts
    22
    Reputation
    113
    Hey ayozzhero thnks very much for your help.
    Prem

  4. #4
    kulrom's Avatar
    kulrom is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 3.5
    Join Date
    May 2005
    Location
    Republic of Macedonia
    Posts
    2,855
    Reputation
    264
    Also, note that you can change font for each control within certain Form:

    Dim xFont As Font

    Dim xControl As Control

    xFont =
    New Font("Times New Roman", 10, FontStyle.Regular)

    ForEach xControl In nform.Controls

    xControl.Font = xFont

    Next

    Cheers

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking