-
Dec 8th, 2017, 12:01 PM
#1
Thread Starter
Junior Member
[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!
-
Dec 8th, 2017, 01:05 PM
#2
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.
-
Dec 8th, 2017, 02:06 PM
#3
Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?
Originally Posted by Sitten Spynne
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
-
Dec 8th, 2017, 03:28 PM
#4
Thread Starter
Junior Member
Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?
Originally Posted by 4x2y
Ok so would I use the "AllowScriptChange" property?
-
Dec 8th, 2017, 03:43 PM
#5
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.
-
Dec 8th, 2017, 03:48 PM
#6
Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?
Originally Posted by VBAppleCoder
Ok so would I use the "AllowScriptChange" property?
It is True by default, why you are worry about it?
-
Dec 8th, 2017, 06:03 PM
#7
Thread Starter
Junior Member
Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?
Originally Posted by 4x2y
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.
-
Dec 8th, 2017, 06:13 PM
#8
Re: How do you use a Font/Color dialogbox to change the Font/Color of a label?
Originally Posted by VBAppleCoder
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.
-
Dec 8th, 2017, 08:55 PM
#9
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.
-
Dec 9th, 2017, 07:50 PM
#10
Thread Starter
Junior Member
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
-
Dec 9th, 2017, 07:51 PM
#11
Thread Starter
Junior Member
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.
-
Dec 10th, 2017, 09:29 AM
#12
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|