I want to save state of radio button in windows form application in visual studio. When I have selected a particular radio button and click next, next form loads and when I return to the previous form, all radio buttons are deselected i.e. the previous state has been not saved. SO how can I resolve this.
The methods I'm using are this.Hide() and form2.Show() after creating an object for form 2.
You can save the selected radio button the Session variable when you leave the first form and then restore the selection from the Session variable on the Page_Load function upon return to the first form.
Related
In my Visual Studio project file: <TargetFramework>net6.0-windows</TargetFramework>
I have a Winforms application whose main form has two buttons, button A and button B.
I have coded button A so that it disables itself when clicked, launches form A, and when form A is closed, control returns to the button click event where button A is re-enabled:
btnA.Enabled = false;
FormA frmA = new FormA();
btnA.Enabled = frmA.ShowDialog(this) == DialogResult.OK;
However this does not allow the user to do anything on the main form until frmA is closed.
When button A is clicked, I still want to disable button A so that the user cannot open another form A. But I also want the user to be able to click button B on the main form and have that logic work the same way: disable button B, launch form B, re-enable button B.
What I am trying to do is give the user the ability to launch one form A and one form B from the main form. Can I accomplish that with the pattern I've described? If so, how? (Note: There could be buttons C and D later.) I would gladly consider a different/better approach. Thanks Hedge.
I found a SO solution using Show() and capturing the close event on Form A:
WinForms; detecting form closed from another form
Not much coding involved at all.
I have a navigation menu to select the settings for the main form. How would I go about making the whole application TopMost from a different existing form.
Picture 1 shows the settings form
How would I be able to change TopMost from the Menu Settings section
I am using panels to display the change between forms.
(Assuming this is WinForms) I think I'd do it by bind to a setting.
On the form you want to be topmost open the form in the designer, click the form background so the Props grid shows props for the form, then expand Application Settings and click the 3 dots next to Property Binding
Drop down next to TopMost and choose New
Call it IsTopMost ...
Then in some code (anywhere, in any form, anywhere.. Such as this button click handler..) change Properties.Settings.Default.IsTopMost
private void button1_Click(object sender, EventArgs e)
{
Properties.Settings.Default.IsTopMost = !Properties.Settings.Default.IsTopMost;
}
If you run this, and then click that button on form2, form 1 will pop to top and be topmost. If you click it again, it will toggle off. If you have some settings form2, and you bind a checkbox to this value, by the same process, then when you click the checkbox on form2, form1's TopMostness will follow the check state of the checkbox on form2.
Regardless how you change that bool in Properties.Settings.Default.IsTopMost, it will influence Form1's TopMostness
I've a WPF page that contains next and cancel navigation to subsequent pages. Next button gets enabled based on certain validations. On click of another button in the page, another .exe gets opened and the 1st page goes to background. After finishing the tasks in opened exe, if the 1st page is not clicked, Next button and close button stay disabled. Once I click on the form, they get enabled.
I checked that if the 1st form is in background, CanExecuteChanged function gets called only when the form is clicked manually.
How to make the 1st form active again after the 2nd exe is closed?
I'm a Student of C# and doing a Windows Form Application using in visual studio 2012. The problem that i have is.
I have a parent form with a menustrip = File, with sub item Login and on Login item Click the Child form loads so you can enter your login details.
The problem that i'm having is when i click the login click button on the Child Form i need to
Add MenuStrip name "Add", with sub items names "Edit","Copy";
Also
Add DatagridView;
To the Parent Form, can anyone give me a step in the right direction please
From my understanding you could go about this two different ways.
First is to use the DialogResult that is received back from childForum.ShowDialog(this);
Which you can set in the child form's closing event. (If you don't need data back from the child form) Very similar to how you get results back from a MessageBox.Show();
Second would be to trigger an event that your main form is listening for that sets your data when received. (If you need to pass data between the two) -
simple custom event
If user don't checked, I want to show asp:ModalPopupExtender and get numeric value from this form.
I'm using asp.net wizard control. I don't know "finish" button id. Can somebody help me?
You should set the target of the ModalPopupExtender as a dummy control, i.e., a hidden Button, LinkButton,... that never is going to be clicked by the user.
The Wizard control have a method called FinishButtonClick. Here is where you have to check the state of the CheckBox and show or not the popup calling to the method Show() of the ModalPopupExtender. You also can call to the Click() method of the hidden control or do it with JavaScript usign the BehaviourID of the ModalPopupExtender. Your choice.
Cheers!
To get "Finish" button id, just open the page in browser & view the rendered html code (Right Click -> View Source). From their you can get the finish button id.
And after getting "Finish" button id, you can easily associate a Client-Side event to do the required job.