Results 1 to 12 of 12

Thread: [RESOLVED] [2005] Changing the colour of a radiobutton

  1. #1

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    Resolved [RESOLVED] [2005] Changing the colour of a radiobutton

    Hi there,

    I am looking to change the colour of the button part of a radio button. So far I have been unsuccessful in finding useful info. I had a look at the System.Windows.Forms.VisualStyles stuff I came across in MSDN but doesn't seem to do what I need it to do or I just didn't understand it properly.
    Could someone point me in the right direction, please?
    I basically want to use the red radiobuttons to show a server is down and a green one to show that it is up. If someone has an alternative solution or suggestion, I'm all ears.

    Gr,
    Mightor
    What the world needs is more geniuses with humility, there are so few of us left.
    If my post was accidentally useful, please rate it as such, thanks!
    Mon aéroglisseur est plein des anguilles.

  2. #2
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [2005] Changing the colour of a radiobutton

    I don't understand. How are you going to use a radio button to show the status of something? Do you have a screenshot of what you are trying to accomplish?
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  3. #3

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    Re: [2005] Changing the colour of a radiobutton

    This is a mock up of what I want to make. I have attached it to this post. This should explain what I am trying to accomplish. The light can be either green or red, depending on the server's status. So they'd act as separate radiobuttons.

    Gr,
    Mightor
    Attached Images Attached Images  
    Last edited by mightor; Apr 26th, 2007 at 02:40 PM. Reason: slight amend of description
    What the world needs is more geniuses with humility, there are so few of us left.
    If my post was accidentally useful, please rate it as such, thanks!
    Mon aéroglisseur est plein des anguilles.

  4. #4
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [2005] Changing the colour of a radiobutton

    In my opinion, you shouldn't be using radio buttons. They weren't designed to show a status like that. Thats just not what they were made for, and I think it will be much harder to achieve this than to take care of it in another way. Why not just use a picture box? Change the image to your green image if it is up, and red if it is down. You could even use those pictures so you get the same effect. Although, people do generally expect to be able to click on a radio button, so you might want to differentiate it common radio button.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  5. #5
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Re: [2005] Changing the colour of a radiobutton

    If you're not actually selecting anything the radio button isn't really a suitable control to use.
    If you just want to indicate the status of the server why don't you just draw a circle next to a label with the text property set to the servers name?
    If my post helps , please feel free to rate it

  6. #6

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    Re: [2005] Changing the colour of a radiobutton

    A nice suggestion. I never considered using regular images to do that. I will give it a try. Thanks for that!
    What the world needs is more geniuses with humility, there are so few of us left.
    If my post was accidentally useful, please rate it as such, thanks!
    Mon aéroglisseur est plein des anguilles.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Changing the colour of a radiobutton

    to do what you want would take allot of sickening code lol. You have to create a class, inherit the radiobutton in it, override the Visual Styles drawing and implement your own.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: [2005] Changing the colour of a radiobutton

    The standard .NET control in this case would be a CheckBox. Why not just use four CheckBoxes? Checked means online and unchecked means offline, or whatever you're trying to indicate.
    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

  9. #9

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    Re: [2005] Changing the colour of a radiobutton

    The reason I don't want to use the checkboxes is because I'd really like to get a traffic light kind of system with green, amber and red. After much scouring, I came across a very nice post in the VB.NET codebank on this site. The cntlOption class is basically what I need, visually. I can change its colours on the fly and once all the nice mouseover and other event handlers pertaining to it changing its colour have been stripped, I think I have the perfect traffic light control
    The code looks simple enough to tweak to my likes, so a big thanks to warrenayen for writing it.

    This may be slightly offtopic, but under what license is the code in the Codebank published or is it public domain? I couldn't find any info regarding this. The application I am writing will be OpenSource, published under the GPL. Will this prevent me from using this code? Obviously if it is public domain, it won't. If someone knows, I'd be very happy to hear about it.
    What the world needs is more geniuses with humility, there are so few of us left.
    If my post was accidentally useful, please rate it as such, thanks!
    Mon aéroglisseur est plein des anguilles.

  10. #10
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [RESOLVED] [2005] Changing the colour of a radiobutton

    I don't know the answer to that, but you might want to start a new thread. People (myself anyway) tend to click less on resolved posts.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

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

    Re: [RESOLVED] [2005] Changing the colour of a radiobutton

    Assume that the code in the CodeBank can be used freely unless specified otherwise in the individual thread.
    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

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] [2005] Changing the colour of a radiobutton

    If you are really concerned, the best thing to do it ask the member that posted it.

    Internet.com owns a type of license on the code posted on the site but who ever posts it actually retains authorship and copyright. Internet.com is licensed to publish the code and use anyway it sees fit I believe, just not allowed to repost something on some other non-jm site.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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