Results 1 to 6 of 6

Thread: Making styles with VB Code...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Making styles with VB Code...

    So if you remember in old VB6 days, if you wanted to change the background color of a button you would just call

    Command1.backgroundcolor = vbBlack

    Now what I am wondering is if I modify a simple style button, make it look the way I want, is there a way to give my users a way of changing the colors (basically making a brush and applying it), etc...
    Visual Basic Rules!!!!!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Making styles with VB Code...

    In WinForms it's much the same as in VB6, e.g.
    vb.net Code:
    1. Button1.BackColor = Color.Black
    In WPF you would create a Brush and assign it to the Background property. If you just want a solid colour then you can use a SolidColorBrush, obtained from the Brushes class,e.g.
    vb.net Code:
    1. Button1.Background = Brushes.Black
    If you want something fancier then you can create some other type of Brush.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Making styles with VB Code...

    With regards to letting the user choose, you could either create a list of SolidColorBrush objects and display their Color properties for selection or, more likely, you would display a list of Colors and then create a new SolidColorBrush from the selected Color.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: Making styles with VB Code...

    So like I have a control I've been working on and it has numerous parts to it... it is based off of the simple style combobox, but I've added and tweaked it so it looks how I want it... So how can I expose fill/brush properties for objects inside the control, instead of just the control itself...
    Visual Basic Rules!!!!!

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Making styles with VB Code...

    It's probably a good idea to actually ask the question you want answered to begin with, rather than working up to it.

    As for the question itself, you pretty much answered it for yourself:
    So how can I expose fill/brush properties for objects inside the control
    You add a property to your parent control and you pass through the corresponding property of the child control. More than that I can't say without a more specific question.

    Also, you should take into account that I've never used WPF myself, so there will be things that I'm not aware of. Others may have more information but all I've answered here came from reading the MSDN documentation after reading your question. That kinda makes me wonder, if I could look up the Button class and read about its Background property, etc., why others couldn't too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: Making styles with VB Code...

    Well these new questions are coming as I learn... I didn't have this question at the time of starting this thread... :/

    Thanks for all the help btw
    Visual Basic Rules!!!!!

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