Changing text font in design time - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Changing text font in design time

mjk2742mjk2742 Posts: 2Member
Just starting to learn vb. My instructor wants textbox font properties to change with a click event while the app. is running. This is probably simple to code, but I could really use some help.
thanks,
mk

Comments

  • SonickeaSonickea Posts: 15Member
    Here's what you can do. It's a generic approach, but I tried it for VB2005:
    Assuming you have the form with the etextbox ready, add a FontDialog control (double click it in the toolbox. Change the name however you want. Then add a button to trigger the font dialog, and double click the button to have the IDE generate a method stub that responds to the default event of the button (single click). Then write somethings as follows:
    '********************
    FontDialog1.Font = TextBox1.Font ' Will show the current font settings of the text box in the dialog
    FontDialog1.ShowDialog()
    TextBox1.Font = FontDialog1.Font
    ' Done!
    '********************

    It's the same in all VB, just a bit different controls.

    : Just starting to learn vb. My instructor wants textbox font properties to change with a click event while the app. is running. This is probably simple to code, but I could really use some help.
    : thanks,
    : mk
    :

  • mjk2742mjk2742 Posts: 2Member
    thx for the reply, I found another way that also works.

    Me.txtText.ForeColor = Color.Red
    Me.txtText.Font = New Font(Me.txtText.Font, FontStyle.Bold)


    : Here's what you can do. It's a generic approach, but I tried it for VB2005:
    : Assuming you have the form with the etextbox ready, add a FontDialog control (double click it in the toolbox. Change the name however you want. Then add a button to trigger the font dialog, and double click the button to have the IDE generate a method stub that responds to the default event of the button (single click). Then write somethings as follows:
    : '********************
    : FontDialog1.Font = TextBox1.Font ' Will show the current font settings of the text box in the dialog
    : FontDialog1.ShowDialog()
    : TextBox1.Font = FontDialog1.Font
    : ' Done!
    : '********************
    :
    : It's the same in all VB, just a bit different controls.
    :
    : : Just starting to learn vb. My instructor wants textbox font properties to change with a click event while the app. is running. This is probably simple to code, but I could really use some help.
    : : thanks,
    : : mk
    : :
    :
    :

Sign In or Register to comment.