Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.