Use two forms to do it on winform - winforms

Use 2 forms to do this on winform.
opacity set first form 40%
Call the second form in the first form as follows
Form2 f2 = new Form2 ();
f2.Owner = this;
f2.Show ();

Related

How to pass value into textbox from Page to main form in WPF?

Can't set value to textbox from Page to form
I have a main form with frame where I load page
Frame1.NavigationService.Navigate(New PieDonut2DChart.pagOpenTicketsByMember()) and textbox txtFrame1.
Now I want from page set value:
Dim mainForm as frmMain1 = New frmMain1()
mainform.txtFrame1.Text = "Test"
But code not working.

C# how to make a child form topmost only inside the application?

I have 5 child forms in my c# application. one of the child forms named childFormopens another form subForm. What i want is, when subForm is open, user cannot click or do anything inside the application without closing subForm. But this should be contained in the application only. i.e When user wants to switch to another application without closing subForm he/she wont see subForm anymore, again if user switches to the c# application the subForm form must be on top and rest of the control must be disabled.
to create and show the subForm from within the childForm i wrote a button_click event
Imagine your form contains an editbox, a Button and a close Button (x).
This may help if we have the same SDK.
Button.click += delegate{
Subform();
}
Public void Subform(){
Button closebutton = Resource.Id...;
Button Enter = Resource.id...;
Edittext Edit = Resource.Id...;
Enter.enabled = false;
Edit.editable = false;
Closebutton.click += delegate{
Mainform();
}
}

How to hide a form while we move to next form in Winforms?

I created few Forms while running this project I need to hide the 1st Form while I call the second Form from first Form button on runtime. I tried this code **Login.ActiveForm.Hide();** but it showing error like Object reference not set to instance of object.
I need to hide that From1 while clicking button on Form1 & move onto second Form2 now If I click button on Form2 I need to show that hidden Form1.
Help me to complete this task.
Thanks in advance. Srihari
When you open the next form (presuming it is not opened as a .ShowDialog()) then you can call this.Hide(); to hide the first form.
In the button click event on form2 you can traverse the OpenForms collection and reshow form1.
An example being:
foreach ( Form openForm in Application.OpenForms ) {
if ( openForm.GetType ( ) == typeof ( Form1 ) ) {
openForm.Show();
}
}

How to open a form from a Dialog (modal form) and make it accesible even if didn't close the dialog

I have a form (form1) that I open as modal. In that form there is a button where, when the user presses it, it opens a new form (form2).
I have the problem that form1 is modal and form2 is in the background, and I cannot do anything until I close form1. How can I do stuff in form2 without closing form1?
I need form1 to be modal, I cannot change that. I tried to set the parent of form2 when calling it:
form2.Parent = form1
form2.Show()
But it gave me an error:
"Form cannot be added to the Controls collection that has a valid MDI
parent. Parameter name: value"
So I tried this:
form1.IsMdiContainer = true
But this just puts form2 inside form1. I also tried hiding form1 and then showing it again when form2 is closed, but it fails.
Platform: Windows Forms using VB.NET.
The problem I was having was that it was setting the parent of form2 as the mainform, so I deleted that part and now form2 opens on top of form1.
Another solution that also works is to open form2 as modal. Of course it will act different, but that depends on what you want.

Move one form to another winforms - C#

I have 2 winforms Form 1 and Form 2. I have button1 in form1, when i click on button1 from form1 i display form2.
Form2 ins = new Form2();
ins.MdiParent = this.MdiParent;
this.Hide();
ins.ShowDialog();
I hide the form1 to display form2 when button1 is clicked. This creates a flicking effect and i need to remove this flicking. How do i open/redirect to another form (i am supposed to show only one form at a time and am not supposed to show any top menu like (if i use MDIParent form). Just one active form.
Thanks,
Karthick
It sounds a bit like you're trying to create a web-style UI where the user steps from one "page" (represented by a Form) to another.
Rather than implementing a UI like this with separate forms, you're better off doing it with UserControls hosted on a single parent form.
Have a read of this MSDN article, which includes a download with sample code. It's a great walkthrough for designing that kind of user interface:
IUIs and Web-Style Navigation in Windows Forms, Part 1
IUIs and Web-Style Navigation in Windows Forms, Part 2
Edit
If you're intent on showing two separate forms, is there any reason you need to show the second one modally? Can you not simply show it and then hide the original?
form2.Show();
form1.Hide();
... or do you have yet another form that both form1 and form2 are "modal" to?
To transfer from one page (form1) to another (form2)
suppose form1 contain a button named "SAVE"
we have to write the following code in click event of the "SAVE" button
form2 f2=new form2();
f2.Show();
I think there is a property on winforms if you would like to show it on the task bar or not.
I can clarify your doubt about how to redirect from one form1 to form2
for example:
place a link in form1 and then write following code in it
form2 ins=new form2();
ins.show();
Instead of hide use close option.
Form1 formObject = new Form1();
formObject.Close();
or simply
this.Close();

Resources