radiobutton styling in winForms? - c#

Hey I was just wondering the techniques everyone uses to style radio buttons in winForms. I find them very plain, and would like to add some color or different images for the controls. The only way I can think of is to actually use a button that looks like a radiobutton, and set it to true or false.
Just wondering if there is a way I can do this, but still use the radio control.

Here is the RadioButton MSDN.
Here you can see that you can, like many Controls :
change the Button Apparence.
change the Button Color.
change the Button BackGroundImage.
There are many options to create your CustomRadioButton.

Here are two links which you can use to customize your controls
http://www.devexpress.com
http://www.dotnetskin.net

Related

Custom control creating

How can I make a custom button like in the image below? I searched on Google about custom control, but this is more special, is animated...
I know that on StackOoverflow are more questions like mine, but it is not a duplicate, I want to learn more about this particular button.
It is a button for WinForms.
you can create these buttons with GDI+ in C#,for example look at this one
On Windows form these buttons are made using the BackgroundImage Property of Button Control.
All you need is to toggle the background image on events like Click,OnMouseEnter etc.
This is not a custom control, this is CSS
Have a look at this, http://www.dynamicdrive.com/style/csslibrary/item/css_square_buttons/
You should possibly read something about gif-animation, jquery animation or css3 transitions to be able to animate backgrounds of such element

How can I change the color of a disabled tab control

I have my current program disabling a tabControl on startup until a button is pressed. However I don't like the way that the tab looks when it is grayed out.
I want it to look just the same but still have it disabled. Is there a way that I can do this?
You'll need to draw the TabControl yourself to achieve this. Here's a tutorial on CodeProject.com.
Unfortunately, it takes some time to achieve it but that's up to you of course.
Instead of drawing the TabControl yourself, maybe you could disable the controls on the TabPage instead?
If you're using WPF, you can use templates to customize your disabled style. Please see:
http://msdn.microsoft.com/en-us/library/ms754137.aspx
Notice the visual states for disabled controls, etc.

Silverlight: Custom Radio button

I am trying to develop a custom radio button that looks like a two-option button control that looks somewhat as shown below with toggling of highlighted state. Not sure where to start.
Is there any such controls already available that I can use.
OK, here is a brief overview of what you will need to do ...
Firstly, you will need to change the ControlTemplate for the existing RadioButton control. There are lots of tutorials available that describe this,, for example this one.
Replace the standard template with some suitable markup for your illustration above. Perhaps a two column Grid?
Within each Grid cell add a Rectangle, one behind Option1, and the other behind Option2
Use the VisualStateManager to change the Fill property of each Rectangle based on the controls current VisualState. i.e. when Pressed toggle the background colours.
The steps above should help you achieve your goal. Please read the linked web pages and the Silverlight documentation. If you are still struggling after that,, come back and ask another question.

Hide/show part of the window with a button click

I have a simple form containing a main view and also some text boxes and an "add" button that I use for adding data that is displayed in the main view (and stored in a text file). What I want to do is to add a little button that will toggle hiding/showing of the adding controls. Such button usually is a small square containing two arrowheads pointing up/down depending on the state. How do I do that?
(I'm sorry for the terrible title, but I don't know the proper name for this. Could anyone tell me?)
I don't think there's something built-in in WinForms for that. When I needed to do something similar, I just changed the Height of the form...
this.ClientSize = new System.Drawing.Size(required_width, required_height);
use a bool for hiding/showing
You can use the forms Height property and the controls could be hidden with Control.Visible = false
I think the word you're looking for is "Collapsible panel".
A quick google/codeproject search will provide you with some links:
http://www.codeproject.com/KB/miscctrl/TgXPPanel.aspx
http://www.codeproject.com/KB/miscctrl/XPCollapsGroupBox.aspx
http://www.codeproject.com/KB/miscctrl/CollapsibleGroupBox.aspx
I suggest you use a SplitContainer control and play with the Panel2.Collapsed property by sitting it to true or false
put the control that you want to hide/show inside panel2 and put the button in panel1. Change the Orientation property to Vertical, and there you go

Is there any easy way to hide the radio buttons, checkboxes, etc. without hiding the content?

I'm suspecting the answer is no, but I just want confirmation before I move on - is there any easy way (as in, not re-templating) to hide things like the box that gets checked on a CheckBox, the drop-down arrow of a combo box, etc. without hiding the actual content being displayed?
Try this! Example is for a radio button:
radioButton.Visibility = Visibility.Hidden;
You can play some around with the Background or BorderBrush, but the answer is as you excepted: No..
You will need to restyle the control, but don't let the whole styling and templating scare you though.. Its actually quite easy once you get the hang of it ;)
Notice that you can have a checkbox like button using "ToggleButton", so you could use more or less use the same template as for your normal buttons (if you need them for toggling states).
The answer is YES, as you can actually template all controls a lot, without the need of creading custom controls. Just set the template in a style and add the style to the control.
oh i just reread your question
.. the answer is NO, but have a look at the toggle button maybe its what you are looking for.
the simplest way to display the content of ComboBox, CheckBox, etc. is to display a TextBlock in readonly mode.
You can easily make an UserControl with a DependencyProperty and show/hide your content.
You can disable the control/s in which case they cannot be interacted with but the text is still displayed.

Categories