Results 1 to 8 of 8

Thread: Make some text bold

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Make some text bold

    Is it possible to make only part of a control's text, or a string, bold? It looks like it's all or nothing. Thanks.

  2. #2
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    not sure about textbox... but look into richtext box.

    richNewCode.SelectionFont = New Font(richNewCode.SelectionFont.Name, cmbFont.SelectedIndex - 1, richNewCode.Font.Style.Bold)
    Last edited by nahya^^; Mar 24th, 2004 at 04:39 PM.
    [vbcode]
    Me.Hide()
    [/vbcode]

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Thanks, I can do the rich textbox, but am really looking for a label or string that can be used to set the label's text (or button, whatever). I tried bolding a selection in a richtextbox and setting a label's text to the that, but it lost the formatting.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You can , by drawing the string with DrawString function in the Graphics Class .

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Thanks, Pirate. Never used that before. In the code below, I get an error "Expression does not produve a value" in the call to G.DrawString. Can you see what's wrong?

    VB Code:
    1. Private Sub cmdBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBold.Click
    2.         Dim G As Graphics
    3.         Dim F As New Font(Label1.Font.Name, Label1.Font.Size, FontStyle.Bold)
    4.         Dim x, y As Integer
    5.  
    6.         Label1.Text = "Select a "
    7.         x = Label1.Text.Length
    8.         y = Label1.Height
    9.         G = Me.CreateGraphics
    10.         Label1.Text += G.DrawString("Project", F, New SolidBrush(Color.Black), x, y)
    11.     End Sub

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by salvelinus
    Thanks, Pirate. Never used that before. In the code below, I get an error "Expression does not produve a value" in the call to G.DrawString. Can you see what's wrong?

    VB Code:
    1. Label1.Text += G.DrawString("Project", F, New SolidBrush(Color.Black), x, y)
    Here you are assigning a sub to text property of the textbox control . You can't do that but what do you want to do exactly ?

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    What I'm trying for is for a label text to look like:
    Select a Project
    Thanks.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by salvelinus
    What I'm trying for is for a label text to look like:
    Select a Project
    Thanks.
    Sample :
    Attached Files Attached Files

Posting Permissions

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



Click Here to Expand Forum to Full Width