group standard buttons together in C# - c#

I was wondering if there is a way to group standard windows form buttons together, such as the way radio buttons can be, where only one can be selected at a time. I have four option buttons on my form, but only want one button to be able to be selected, and the background colour to change for the selected button, but if another button is pressed then to remove the background colour on the previous button and change the colour on the new button.
Sorry if this doesn't make sense
Thanks

This approach uses Toggle buttons in a list box and uses selected item binding to managed which one is toggled. This will maintain the button look and add radio button behavior:
How to get a group of toggle buttons to act like radio buttons in WPF?

Related

Allow to the user select two radio buttons in a group at the same time WPF

I am doing a WPF application and I need to allow the user to select exactly two radio buttons that belong to the same group.
Radio buttons do not work that way. You will have to use checkboxes and using the click event make sure that they do not choose more than two.

Radio buttons Navigation by KeyBoard

I have 3 radio buttons on my WinForm.
I would like to give the user the option to navigate between them also by keyboard.
Is there a way to enable it?
I understand I have to use this code:
if (e.KeyChar==Convert.ToChar(Keys.Down))
But how do I know which single radio button I have to set as checked?
The simplest solution is to use keyboard shortcuts. This entails prefixing one character in each RadioButton's text with the & character.
For example if the text of your radio button is "&Big option" then the user can select this option by pressing the [ALT] and B keys at the same time.
Additionally, once one of the radio buttons has the focus you can navigate between them by using the up and down arrows. In general, the user can navigate between controls by using the [Tab] key. In VS 2010 the tab order may be modified by selecting the View->Tab Order menu item.
The same keyboard shortcut trick works for many other controls. For example if you have a TextBox control preceded by a label control you can prefix a letter in the Label control with &. Now since the Label (by default) can't take the focus, when the user uses the Label's keyboard shortcut, the focus will move to the next control in the Tab Order i.e. the TextBox.
If you want a control to be skipped when using the [Tab] key set its TabStop property to False.

Can I change radiobutton control's visibility

In given below Image I am showing radio button ,Can i remove arrow shown circle of radio button ,is it possible ? I need to show on radio button's image and text ,not its sign , I know i can use any other control like button or label, but Actually I have done all coding using radio button ,and now design of form got changed ,and now i don't want to change whole my code again , so is their any trick to solve this issue ?
You can use the Appearance property like this:
radioButton1.Appearance = Appearance.Button;

How to create a menu similar to the Windows 7 Start Menu in WPF

I am contemplating having a menu in my WPF application that works in a similar way to the Windows 7 start menu.
In my mind, this means that I should make a user control that consitues a button. Clicking on the button will display a list box, and inside the list box it will be possible to search the items that are registered in the list box.
Would that be an advisable way of doing it or is it better to do something different such as changing the template of a menu control?
Thanks for any help, it is very much appreciated.
It seems you have the design already made up. Do exactly that! :) Create a button that when pressed, displays a panel that contains a list box and a text box. Tie an event to key presses in the text box that changes what the object bound to the list contains.
After that, it's just a SMOP!

Getting handle of Autocomplete dropdown box of textbox in winforms

I wanted to adjust the width of the Autocomplete dropdown box of a textbox. I dont want to adjust the width of that textbox, but only Autocomplete dropdown. I know that there is no way I can increase the width of the Autocomplete dropdown by using properties provided with textbox.
Hence I wanted to know whether there is any way to get the handle of that Autocomplete box and then increase the width of that drop downlist without changing the textbox width?
If this is not possible then I would like to create my custom textbox with autocomplete, in this case how to use the existing autocomplete functionality provided by microsoft? Is there any way to do it. Are there any libraries available for this?
I don't think you can use Microsoft's implementation of autocomplete, which does not have an option to adjust dropdown width.
Create a background thread to not get into the way of typing, and hook up the text change event of a combobox box or a textbox to update the candidate list (assuming autosuggest mode since you mention a dropdown). You can probably add/remove the combobox items on the fly if you have a combobox. But for dropdown list and textbox items you need a popup window
It is easy to get a popup to show, but you need to not use a fixed position so it won't go off the screen when the textbox is close to the edge of the screen. And the focus logic is a little bit complex. you need to keep focus on the textbox unless the user press the arrow keys to make a selection.
so
when focus is on textbox:
arrow keys move the focus to the popup
other keys goes to the textbox, if not handled by the dialog itself, except for the delete key when mouse is over the popup.
when focus is on popup:
arrow keys move the focus to the sibling candidate item or the textbox
other keys goes to the textbox, if not handled by the dialog itself, except for the delete key
mouse clicks:
dismiss the popup outside of the popup or the popup.
update the value of textbox if a candidate item in the popup is clicked on
It takes a lot of effort to get the focus/threading right. If you can afford some form space, you can just add a fixed width listbox to the form instead, like Visual Studio help viewer's index pane.
After going through lot of blog posts and different articles, I came to a consensus that it is next to impossible to get a solution to my problem in the way I wanted. So I've decided either to come up with a custom solution or as Sheng Jiang said I need to implement my own autocomplete object.
I've come up with a solution which fits my requirement by increasing the width of the textbox as per the largest string in the autocomplete string list while I'm adding the autocomplete custom source. As I said I cant increase the width of the text box because of the size constraint on the form, so I decided to keep this textbox in a panel and increase the size of the textbox inside that. Panel will not grow with the textbox so that solved my problem.
I know this is not perfect solution but it fits my requirement.

Categories