Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Nov 2002
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Toggle bold (VB.NET)

    I am trying to use a menu item (Bold) to toggle the bold property iof a text box on and off.

    txtBox.font.bold =True(False) give a "property bold is read only" message.

    Does anyone have any suggestions on how to do this?

    Thanks

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle bold (VB.NET)

    The bold property of the System.Drawing.Font object is read-only.

    You can approach this by creating two font objects and specifying the Font Style (bold, italics, regular, etc) in the constructor for each. Then you can assign the desired font object to the Font property of the textbox. Like this:

    Dim BoldFont As New System.drawing.Font(Me.TextBox1.Font, FontStyle.Bold)
    Dim NormalFont As New System.Drawing.Font(Me.TextBox1.Font, FontStyle.Regular)

    If Me.TextBox1.Font.Bold Then
    Me.TextBox1.Font = NormalFont
    Else
    Me.TextBox1.Font = BoldFont
    End If

    Hope this helps

Posting Permissions

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