Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
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.

Can I change font size ?

honest_dudehonest_dude Posts: 93Member
I have made this simple application using vb.net2003 and xml database. My form on the text box display from the .xml database, I need to put a button so that a user can change the font size which is display on the form through text box which was taken from the xml database ie. make the fonts bigger or smaller when using the program and reading the text on my form.

Is there anyway I can make a command button which will change the font size on my program.
Would be grateful if someone throw a light on my problem.

Thanx.

Comments

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    Not sure if I am understanding what you are asking exactly, here is something to try and think about:

    [code]
    Dim Size As Single = 11
    If IsNumeric(TextBox1.Text) Then
    Size = CType(TextBox1.Text, Single)
    End If

    Button1.Font = New Font("arial", Size, FontStyle.Regular, GraphicsUnit.Point)
    [/code]

    You can replace Button1.Font with the Object.Font of what you want to change, TextBox1.Text should replaced with the name of the textbox object you have.

    This code would go in the ButtonClick event.
  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    Edit: oops, double posted
  • honest_dudehonest_dude Posts: 93Member
    Many thanks. Can I make my character bold and italic too if my text file is in .xml and display those text through a text box on my form.
  • honest_dudehonest_dude Posts: 93Member
    Well thanks for the response, but what i mean is to put a control button on my form so that i can change the font size i.e increase or decrease which is display on the text box. Can you give a hint or a small code to do that. Would be very grateful.

    Thanks anyway.
  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    I think your wording is off a little. I think this is what you are looking for:

    [code]
    Private Sub btnFontSize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFontSize.Click
    Dim FD As New FontDialog
    Dim DiRes As DialogResult
    DiRes = FD.ShowDialog
    If DiRes = Windows.Forms.DialogResult.OK Then
    'They accepted the new font in the font Dialog
    TextBox1.Text = FD.Font.Size
    End If
    End Sub
    [/code]

    You will have to change the Button click even that this code is in, you will have to change TextBox1.Text to the text box you want to put the font in. You could have found this on google in 5 minutes...
    -Sean Campbell
Sign In or Register to comment.