I have 2 forms in my app at the moment. The main form calls another form from a menu option. I have got that working. On the second form, when OK is clicked I want to close the from (easy) and make the first form become active again. But the code is on the btnClick on the second form and I can't seen to access the first from enable or show properties.
So I suppose the question is - how do u make a control on one form access the properties on a different form.
i have tried
frmMain.show()
frmMain.Enable();
but the .show() or .enable() are not appearing on intelli type (or what ever its called).
Loading
VulpesPosted Apr 13, 2011, 5:34 AM
Richard BrennanPosted Apr 13, 2011, 8:33 AM
Thanx for all your input every one. Lets close this one - finally lol.
Sam HobbsPosted Apr 12, 2011, 8:58 PM
Are you sure you need to minimize the form? Another possibility would be to hide it, then show it again when the other window is closed.. Another possibility would be to show the other form as a dialog, and then the system will automatically take care of disabling the main form while the other form is shown. Another possibility is to show/hide both forms as appropriate (show one and hide the other).
Richard BrennanPosted Apr 12, 2011, 5:29 PM
The situation
Main form: LogOn
Otherform: Change PAssword
On the main form - there is a change password option. When selected 'main form' minimises and Otherform appeares. Thats fine.
The problem is when i click ok on otherform - i can hide otherform - but i cangt get 'main form' to come back. The code above is the code i currently have on otherform. I hope that clarifies the situation for all u keen helpers.
VulpesPosted Apr 12, 2011, 4:11 PM
Richard BrennanPosted Apr 12, 2011, 1:30 PM
My problem in detail, I have a main form with the following code:
frmSplash frmSplash = new frmSplash();
frmAbout frmAbout = new frmAbout();
frmChangePassword frmChangePassword = new frmChangePassword();
frmStudent frmStudent = new frmStudent();
frmStaff frmStaff = new frmStaff();
frmAdmin frmAdmin = new frmAdmin();
and all these forms can be opened from the mainform (frmLogOn in this case).
When change password is selected, this code is used.
private void changePassword()
{
this.WindowState = FormWindowState.Minimized; //minimize logon form
frmChangePassword.ShowDialog(); //show change password form
}
EVERY THING OK SO FAR ;)
On the change password form has code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Web_Spinner
{
public partial class frmChangePassword : Form
{
public frmChangePassword()
{
InitializeComponent();
}
private void frmChangePassword_Load(object sender, EventArgs e)
{
this.txtChangePasswordUsername.Focus();
}
//Buttons
#region buttons
private void btnChangePasswordOk_Click(object sender, EventArgs e)
{
bool valid = true;
//validate user name and password
if (valid)
{
//update password
I want to hide the current form: .hide() i guess is best ;)
I then want get the logon Form showing. Every time I use
frmLogOn. nothing that i know how to use comes up.
do i have to add
frmLogOn frmLogOn = new frmLogOn();
frmLogOn.Show(); - and if so will this make multiple instances of this form as it was opened when the program was first loaded?
Probably very simple but Im a self taught newby and simple things are sometimes confusing lol.
}
else
{
this.txtChangePasswordUsername.Text = "";
this.txtChangePasswordPassword.Text = "";
this.txtChangePasswordNewPassword.Text = "";
this.txtChangePasswordConfirmPassword.Text = "";
this.txtChangePasswordUsername.Focus();
}
}
}
}
Karthikeyan AnbarasanPosted Apr 8, 2011, 6:11 AM
Sam HobbsPosted Apr 8, 2011, 5:43 AM
piyush sardharaPosted Apr 8, 2011, 5:13 AM
1st from in 1st panel
and
2nd from in 2 panel
then to use 2 from
1st panel visible =flase;
and otherwise
panel 1 is visible =true;
you can try it;
VulpesPosted Apr 8, 2011, 4:51 AM
FroglegPosted Apr 8, 2011, 2:23 AM
Sahil JaniPosted Apr 8, 2011, 1:27 AM
I think you have given the link of the 2nd form in menu option. Likewise, you just give the link of the 1st form to the button.
protected void button1_Click(object sender, EventArgs e)
{
String url = "~/form1.aspx?" + "" + "Action=approve";
Response.Redirect(url);
String queryString = null;
if (Request.QueryString["Action"] != null)
{
queryString = Request.QueryString["Action"].ToString();
}
else if (queryString == "approve")
{
//
}
}
This code might help to you.
If it will help it to you then marked this answer as "ACCEPTED ANSWER"
Sam HobbsPosted Apr 7, 2011, 8:12 PM
First I will say that it is highly unlikely you need to access the first form from the second one, especially if you are doing what I think you are doing.
How are you showing the second form from the first? Are you using ShowDialog or Show? ShowDialog will make the form modal and Show will make it modeless. Modal means that the first form cannot be used again until the second form is closed. Modeless means that both can be used at the same time. My guess is that you want to make the second form modal so use ShowDialog.