Results 1 to 16 of 16

Thread: [RESOLVED] ColorBox ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Resolved [RESOLVED] ColorBox ?

    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

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: ColorBox ?

    Have you looked at the colordialog?
    Attached Images Attached Images  

  3. #3
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

  4. #4
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: ColorBox ?

    Have you checked? I'm sorry but really, just open up a project and look in the toolbox (that's a yes).
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: ColorBox ?

    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

  6. #6
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: ColorBox ?

    Quote Originally Posted by x DeaDLy View Post
    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
    Huh? You just want it to open whenever it feels like it?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: ColorBox ?

    NVm i got it, thx much code is
    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         ColorDialog1.ShowDialog()
    3.     End Sub

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: [RESOLVED] ColorBox ?

    Now how do i make it so that when i choose the color, label1.text changes?

  9. #9
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [RESOLVED] ColorBox ?

    Quote Originally Posted by x DeaDLy View Post
    Now how do i make it so that when i choose the color, label1.text changes?
    See my link in post #3. There you will find an example.

  10. #10
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [RESOLVED] ColorBox ?

    Quote Originally Posted by x DeaDLy View Post
    Now how do i make it so that when i choose the color, label1.text changes?
    Do you really mean that? You want to change the label's text, or do you mean you want to change the label's color?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: [RESOLVED] ColorBox ?

    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:
    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

  12. #12

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: [RESOLVED] ColorBox ?

    Quote Originally Posted by keystone_paul View Post
    Do you really mean that? You want to change the label's text, or do you mean you want to change the label's color?
    LoL sorry bout my wording, yes you are correct and i did find a way to do that, i have another question above this post. Thanks so much

  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: [RESOLVED] ColorBox ?

    NVM i found it out, lol thx so much guys =] here is code:
    vb 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.         MyDialog.Color = Label1.ForeColor
    10.         If (MyDialog.ShowDialog() = Windows.Forms.DialogResult.OK) Then
    11.             Label2.ForeColor = MyDialog.Color
    12.             Label1.ForeColor = MyDialog.Color
    13.         End If
    14.     End Sub

  14. #14
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: [RESOLVED] ColorBox ?

    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

    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
    Where in the entire thing is Label mentioned? Only one place, here:
    Code:
                      Label2.ForeColor = MyDialog.Color
    So if you want for another label to change color then really, what do you think your going to do?
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  15. #15
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [RESOLVED] ColorBox ?

    This

    Code:
            ' Sets the initial color select to the current text color,
            MyDialog.Color = Label2.ForeColor
            MyDialog.Color = Label1.ForeColor
    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.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: [RESOLVED] ColorBox ?

    Quote Originally Posted by Vectris View Post
    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

    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
    Where in the entire thing is Label mentioned? Only one place, here:
    Code:
                      Label2.ForeColor = MyDialog.Color
    So if you want for another label to change color then really, what do you think your going to do?
    LoL ya i did do a lil thinkin den found out, just posted the post a lil earlier. Thanks guys

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