Results 1 to 12 of 12

Thread: [RESOLVED] How do you use a Font/Color dialogbox to change the Font/Color of a label?

  1. #1

    Thread Starter
    Junior Member VBAppleCoder's Avatar
    Join Date
    Oct 2017
    Posts
    26

    Resolved [RESOLVED] How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Hello everyone!
    In my project I have a menustrip that contains a "Font" tab and a "Color" tab. I have them coded to where when you click on either or the appropriate dialog box comes up. What I am wanting to do is when opening the "Font" dialog box, I would like to be able to change the font of only one label. Same thing with color, when I open that dialog box I would like it to change the background color of that particular label. So my question is... How do a use the Font dialog/ Color dialog boxes to change the Font/Color of one particular label?

    Hope this makes since!

  2. #2
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Dialogs always work the same way:

    • You call their ShowDialog() method and check its return value to make sure the user clicked 'OK'.
    • If they clicked OK, you check the dialog's properties to see what the user selected.
    • You use those values to set the appropriate properties of something else.


    This is demonstrated in the FontDialog documentation. The example displays the dialog and changes the font properties of a TextBox based on the user's selection. That is very close to what you asked. If you have trouble adapting it, give it a try anyway, post what didn't work, and let us help you out.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Quote Originally Posted by Sitten Spynne View Post
    This is demonstrated in the FontDialog documentation.
    The same documentation but with various language example https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx



  4. #4

    Thread Starter
    Junior Member VBAppleCoder's Avatar
    Join Date
    Oct 2017
    Posts
    26

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Quote Originally Posted by 4x2y View Post
    The same documentation but with various language example https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
    Ok so would I use the "AllowScriptChange" property?

  5. #5
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    That isn't in the example on the page, so no. Stick to what's in the example.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  6. #6
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Quote Originally Posted by VBAppleCoder View Post
    Ok so would I use the "AllowScriptChange" property?
    It is True by default, why you are worry about it?



  7. #7

    Thread Starter
    Junior Member VBAppleCoder's Avatar
    Join Date
    Oct 2017
    Posts
    26

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Quote Originally Posted by 4x2y View Post
    It is True by default, why you are worry about it?
    I am worried because this is for a final exam and it has stumped me. I still can't figure it out.

  8. #8
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Quote Originally Posted by VBAppleCoder View Post
    I am worried because this is for a final exam and it has stumped me. I still can't figure it out.
    So, just concentrate in the properties you want Font and Color and leave all the others, you don't have to set them.



  9. #9
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    There is an example with ten lines of code that doesn't mention the property you are worried about. Maybe try reading that part of the page.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  10. #10

    Thread Starter
    Junior Member VBAppleCoder's Avatar
    Join Date
    Oct 2017
    Posts
    26

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    I figured it out after two days! It was so simple! I was wanting it to use all system colors/fonts and be able to change that label however I want. Not just one color.

    My code: This segment opens a color dialog box and then applies the selected color to the background of the label.
    ' Show the color dialog box
    cdColor.ShowDialog()

    ' Change the color of the account balance box
    lblBalance.BackColor = cdColor.Color

    My code for Font: This segment is basically the same as color except you use this dialog box to change font.
    ' Show the font dialog box
    fdFont.ShowDialog()

    ' Change the font of the label
    lblBalance.Font = fdFont.Font

  11. #11

    Thread Starter
    Junior Member VBAppleCoder's Avatar
    Join Date
    Oct 2017
    Posts
    26

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Your link had the answer in front of me the whole time i just did not see it. Thanks!
    Last edited by VBAppleCoder; Dec 9th, 2017 at 08:17 PM.

  12. #12
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?

    Yes, MSDN shuffles things around every few years and tries to make sure the most useful parts are at the bottom of the page. I learned to just look for the "Remarks" and "Example" links.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

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