Does visual basic 2008 have a colorbox like delphi 2007? If not what other choices are there to create a advanced color chooser. I want it so that the user gets to choose the type of color of the text. Thanks
Printable View
Does visual basic 2008 have a colorbox like delphi 2007? If not what other choices are there to create a advanced color chooser. I want it so that the user gets to choose the type of color of the text. Thanks
Have you looked at the colordialog?
Have you checked? I'm sorry but really, just open up a project and look in the toolbox (that's a yes).
I saw that but it doesn't pop out, do you have to set a button to make it pop out? like show.colordialog ??thx
NVm i got it, thx much code is
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ColorDialog1.ShowDialog() End Sub
Now how do i make it so that when i choose the color, label1.text changes?
Thx now one more question, how do i make it so that more than one label, ex. label1, label 3, are changed using this code:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyDialog As New ColorDialog ' Keeps the user from selecting a custom color. MyDialog.AllowFullOpen = False ' Allows the user to get help. (The default is false.) MyDialog.ShowHelp = True ' Sets the initial color select to the current text color, MyDialog.Color = Label2.ForeColor If (MyDialog.ShowDialog() = Windows.Forms.DialogResult.OK) Then Label2.ForeColor = MyDialog.Color End If End Sub
NVM i found it out, lol thx so much guys =] here is code:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyDialog As New ColorDialog ' Keeps the user from selecting a custom color. MyDialog.AllowFullOpen = False ' Allows the user to get help. (The default is false.) MyDialog.ShowHelp = True ' Sets the initial color select to the current text color, MyDialog.Color = Label2.ForeColor MyDialog.Color = Label1.ForeColor If (MyDialog.ShowDialog() = Windows.Forms.DialogResult.OK) Then Label2.ForeColor = MyDialog.Color Label1.ForeColor = MyDialog.Color End If End Sub
EDIT: Ok I see you got it, but please do some thinking before you post!
Deadly, please do some thinking here, lets look at your code
Where in the entire thing is Label mentioned? Only one place, here:Code:1.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
2.
Dim MyDialog As New ColorDialog
3.
' Keeps the user from selecting a custom color.
4.
MyDialog.AllowFullOpen = False
5.
' Allows the user to get help. (The default is false.)
6.
MyDialog.ShowHelp = True
7.
' Sets the initial color select to the current text color,
8.
MyDialog.Color = Label2.ForeColor
9.
If (MyDialog.ShowDialog() = Windows.Forms.DialogResult.OK) Then
10.
Label2.ForeColor = MyDialog.Color
11.
End If
12.
End Sub
So if you want for another label to change color then really, what do you think your going to do?Code:Label2.ForeColor = MyDialog.Color
This
Is a bit pointless (or more specifically the 2nd line is) - you are setting the color to one thing and then immediately overwriting it again.Code:' Sets the initial color select to the current text color,
MyDialog.Color = Label2.ForeColor
MyDialog.Color = Label1.ForeColor