The problem like this, I have a groupBox which contains two radio buttons, when I run the form, the first radio button get checked immediately, so I tried the following:
Set the check property for this radio button to false in Load form.
Set the check property for this radio button to false in the form constructor.
Change the tab index property for this radio button, the selection moved to the next radio button in the form.
None of the above worked with me, any suggestions??
You could try setting it to false in the form SHOWN event instead of the form LOAD event as outlined in this question.
As soon as any of the radio buttons get focus it'll be selected, so you need to set initial focus in the form to another control than any of those radio buttons (worst case I suppose you could have a hidden radio button or other control and give that focus, but I'd not recommend it since it looks funny).
The intent of a radio button set is to provide choice between a set of distinctive and exhaustive values.
That means, that at all times, one and only one radio button should be selected.
If this functionality does not suite your application logic, maybe the logic is flawed, or maybe radio-buttons are not the best UI solution.
As mentioned, a radio button group displays its behavior as soon as any of the radios get focus, which can happen even with just tabbing around the form, so basically the behaviour of the form depends on the user behaving nicely.
Related
I have a set of sixteen radio buttons. When i press a radio button, i want two buttons to appear (on/off). and when i press any button, a function executes(i have no problem with this),;
when i go to the next random radio button and press it, the same thing should happen., but when i go back to the previous radio button that i pressed, it should still show the action that was carried out(i.e either on/off). It should retain the action carried out on it forever, until manually changed.\
all i need is the demonstration of the above in code for at least 3 buttons, and i will figure out the rest myself....
thanks
Use a trigger in the XAML, it is fairly simple..
http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx
So basically you would use the checkbox value of the original to either show or hide (the property in the style to modify) the others.
If XAML is not your cup of tea and you wish to use codebehind (really personal choice) this may help you.. I am not a WPF/MVVM stickler by any means (some duct tape helps now and then) but putting all sorts of events like this in the codebehind can get messy..
http://www.codeproject.com/Articles/28959/Introduction-to-Attached-Behaviors-in-WPF
This should be a relatively simple javascript item you need to do. Ensuring that you have ids for each of the items then make all the changes on the page and then on the final postback you will have all the correct values
I have a C# user control.
In this control, I have a GroupBox that includes radio buttons and textboxes.
When the user switches between the radio buttons, a message box is raised to ask the user if he is sure in his selection.
The top of the messagebox is covering the last radio button and the last textbox.
In a case the user selects NOT to apply the radio button changes, the messagebox is getting closed, but the last radio button (that was covered by the messagebox) disappered. (The last textbox that was also covered by the messagebox is not getting disappered).
This is kind of refresh problem, because when I move the mouse button on the place of the last radio button, it appears again and everything is fine. (it appears again also if I minimize and maximize my application, etc).
I tried to run the methods Show() and Refresh() on the last radio button after closing of the messagebox, but it doesn't work.
What else can I do?
Thanks
Try Application.DoEvents() after the MessageBox closes to ensure there are no other processes in the processing queue. This should re-show the button but it is difficult to tell if you do not show any code as there could be other issues.
I have an "On screen keypad" with some up/down/left/right/select buttons.
The select button is effectively a click and the arrow keys fire the associated up/down/left/right key.
The problem is that when selecting a combo box, I can't press the down/up buttons to navigate the items in the list. It is because the combo box auto closes when loosing focus. I can see similar problems happening with other controls, so I would like to see if there is a way to do the following.
For certain buttons (up/down/etc), when clicked, fire the click event, but don't take focus from w/e currently has the focus. This would allow the combox dropdown to stay open while pressing up/down to navigate through the items.
I have tried to set Focusable=False on the navigation buttons but the focus is still taken away from the combo box and the dropdown closes.
Any ideas/suggestions?
Thanks in advance
This isn't happening because of anything your Buttons are doing so changing their focus state won't make any difference. ComboBoxes close when you click anywhere outside of them, including empty space, non-interactive controls, other windows...
I have been googling this question, but so far nothing found.
Is there some function, that enables me to remove or hide an button (in wpf)?
For example:
A form with 2 buttons on it:
On initialize, only button 1 will be visible
Click button1, this will make button2 visible
Click button2, this will make button1 get removed (or hidden).
Is such a thing possible in c# in WPF?
Look at setting it Collapsed on one click and uncollapsed on the other
For Button 1's ClickEvent
button2.Visibility = System.Windows.Visibility.Collapsed;
It is possible and very easy to do, just use the buttons click event handlers to toggle the other buttons visibility property.
And one more important thing you have to give a name to your buttons so you can use them from code behind.
MSDN Visibility Property
I have eight radio buttons on a user control. Each of them has or will have their own click handler. The first one has its click handler called when the user control is added to the main window. Is this normal behavior for Windows Forms (I am relatively new to .NET from a Java background)
This effect is likely the result of the default control selection rather than the control being added to the form. When the form finishes loading, one of the controls on the form will become the active control/have focus. If that control is a radio button, the button becomes checked, which will fire events like Click and CheckChanged (unless the radio button Checked property was already set to true). Depending on the Checked property value of the other buttons, you may see their CheckChanged events fire as well.
To test this out yourself, change the TabIndex property value in the designer so that some other control on the form will have the lowest index. This will make that control have focus on startup instead of the radio button(s). When this happens, you should not see the Click event being fired when the form is loaded.