Radio buttons, each when clicked displays two buttons, on and off - c#

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

Related

problem with radio buttons

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.

Is there any Radio grop button in .net winforms?

There is option called checkedListBox1 for check box group item..
Like that any control for radio button. and how to bind my data(data set) in that.
User container to have same functionality as like group name.
container can be group box or Panel
There is no such thing for radio buttons. You may, however, look for third party controls or extend the existing CheckedListBox so that only one item at a time can be checked.
The second solution is a bit ugly, because seeing check boxes the user would expect to be allowed to select more than one option.
Put the radio buttons in their own panel, and they will work together, with only one button in the panel being selectable.
As for data-binding, there are several approaches available, such as creating a form Boolean property for each option, and binding each radio button to its property.
An easier approach would be to use Jay Andrew Allen's RadioPanel, which takes care of binding the radio button options to an enumeration field.

How to Set Up Winform Textbox Field Focus so a User Can Go Through Them by Clicking Tab Button?

UI is created in VS 2008. I'm using C# .... I need to let the user move/focus between text fields from top to bottom by clicking tab button. How can i do it?
On the Layout toolbar (will normally show up if you're in Design View) click on the buttom on the most right (it's called tab order).
Now on every element on your designer will come up a little box with a number. Just click all your elements in the order you like and they will automatically be re-ordered.
If you like to do it manually, just take ho1 advice and change the property manually.
You just set up the TabIndex property properly, so that it's sequential from top to bottom. Then it'll work automatically and you won't need any code to move around the focus.
So in other words, set the top TextBox TabIndex to 1, the next one you set to 2 etc and then one at the bottom will have the highest number (of the textboxes, you probably want to have even higher indexes for any OK buttons and similar so that the user can jump to them after editing all the textboxes).
You can find more info about it here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabindex.aspx

Dynamically adding a textbox to a panel on button click

I just don't understand how this is done. I've gone through several questions here and from a few other websites.
Basically, a company will be adding process steps, and I want there to be a textbox with a button next to it that reads "Add another step." Once clicked, a new textbox will appear beneath the current one, and the button will be moved next to the new text box. What do I need to do?
Well things will get a little more complex once you ask how to maintain ViewState. However, since you didn't ask that (yet), the simple answer is just that on button click event you should instantiate a new TextBox and Insert it into the Controls before the Button.
Okay, finally found an answer I can understand. Using listviews seems to be a good way to go. I found this website
http://geekswithblogs.net/QuandaryPhase/archive/2008/10/19/asp.net-alternatives-to-dynamic-controls---part-1.aspx
And I got the results I wanted.

Confirmation on switching between tabs

I have two tabitems. User will enter some data and save it on the first tab. The second tab lists the saved data. What I need is when the user select the second tab before saving data in first tab a confirmation message box with Yes, No and Cancel should be shown. If the user clicks Yes button the data should be saved and go to the second tab. If he hits No, the data need not to be saved and finally if Cancel is hit the tab will retain with all entered data. How can i make this?
To keep things simple you can do the follwing in the Code Behind file.
I'd create a Model class of the data you want to display and edit in the WPF Control. Make the Model implement the INotifyPropertyChanged and IEditableObject interfaces.
INotifyPropertyChanged will allow you to Bind to the Model.
IEditableObject will allow you to provide Edit, Save and Cancel functionality.
The TabControl has a SelectionChanged Event you can handle, that will allow you to detect when the user changes tabs, in this handler you can use System.Windows.MessageBox to ask the user to save etc, System.Windows.MessageBox.Show() returns a MessageBoxResult Object you can use to detirmine what button the user clicked and perform the appropiate action.
This is not a geat way to do things, but it keeps things simple, you may want to look into some WPF design Patterns to help with Code Manageability.
If you need anything explained further, just ask.
Although I disagree with the way you interrupt the user's flow from tab to tab I'm going to humor you and answer the question:
You'll need two things to get this done:
The event that occurs when a tab was clicked
The previous tab that was selected (the one you came from)
The first item:
The tab control has a Click method that you can subscribe to:
Click=”MyTabButton_Click”
The second item:
This part you'll have to do manually. You can set a variable in the click event which contains what tab was last selected. Once this is set you can check a variable (which you previously set) as to what tab was previously selected. You can then do all your validation.
Delphi's TPageControl has an OnChanging event with an "AllowChange" parameter. I guess there is something similar in WPF.

Categories

Resources