[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
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?
1 Attachment(s)
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
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.
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?
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!
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. :(
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.
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.
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.
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.
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.