i have a login form ,mainmenu form and few other forms i have set my mainmenu form as a MDI container but the login form is acting as parent form and all my child forms are not opening within the parent form but opening as new form and its getting accumulated inmy taskbar and child forms not getting minimised when the parent form is minimised. |
| harini_pavi Friday, July 10, 2009 5:45 AM |
Okey in the Program.cs file show your form like this.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginForm frmLogin = new LoginForm();
frmLogin.ShowDialog();
Application.Run(new MdiForm());
}
And while opening the child form set the mdiparent.
:: Learning .Net :: - Marked As Answer byKira QianMSFT, ModeratorThursday, July 16, 2009 6:49 AM
-
|
| Prasant Swain Friday, July 10, 2009 2:40 PM |
Hello harini, You can try like, when user successfully logged in, start separate application of Mainmenu form, by using Process.start( mainmenuform.exe /*Application name*/). - Marked As Answer byKira QianMSFT, ModeratorThursday, July 16, 2009 6:49 AM
-
|
| NareshG Friday, July 10, 2009 6:01 AM |
Hello harini, You can try like, when user successfully logged in, start separate application of Mainmenu form, by using Process.start( mainmenuform.exe /*Application name*/). - Marked As Answer byKira QianMSFT, ModeratorThursday, July 16, 2009 6:49 AM
-
|
| NareshG Friday, July 10, 2009 6:01 AM |
Okey in the Program.cs file show your form like this.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginForm frmLogin = new LoginForm();
frmLogin.ShowDialog();
Application.Run(new MdiForm());
}
And while opening the child form set the mdiparent.
:: Learning .Net :: - Marked As Answer byKira QianMSFT, ModeratorThursday, July 16, 2009 6:49 AM
-
|
| Prasant Swain Friday, July 10, 2009 2:40 PM |
Hi all! Thanks a lot it worked :)..I have another query..like i am not using default menu strip for navigating to the child forms,instead i am using some controls like buttons and links for navigating to the child forms and i have placed those controls in the MDI Container . so i want those controls to disappear on link/button click(ie when the child form opens)andreappear when i exit the child form .All this should happen within the MDI or the parent form and no new window should be opened in the taskbar .. |
| harini_pavi Monday, July 13, 2009 9:31 AM |
hey i have a doubt regarding this code [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
LoginForm frmLogin = new LoginForm(); frmLogin.ShowDialog(); Application.Run(new MdiForm()); } by executing this code the MdiForm is openingjust by clicking the close button of the login form.it is notmaking it compulsory to enter theuserid and password .How do i solve this problem.Should i have to give somethin like environment.exit() in the login form closing event in order to exit the application when the close button (login form ) is clicked.. |
| harini_pavi Thursday, July 16, 2009 12:30 PM |
When the user click on the close button of the login form just exit the application. Application.Exit();
private void btnClose_Click(object sender, EventArgs e){ Application.Exit();}
|
| Prasant Swain Thursday, July 16, 2009 12:44 PM |
i am not using a close button but using a default close which comes along with Fixed Dialog(Form border style) and apart from that in the submit button of the login form after successful login i have written a code namely (this.close) for the login form to close.which in this case ll close the whole application after successful login. |
| harini_pavi Thursday, July 16, 2009 1:54 PM |
Can anybody help me out with the above query?? |
| harini_pavi Wednesday, July 22, 2009 3:56 AM |
On login form set The DialogResult Property of Ok and Close button (like Ok and Cancel) , and change the code as given below.
[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
LoginForm frmLogin = new LoginForm(); DialogResult drResult = frmLogin.ShowDialog();
if (drResult== DialogResult.OK) // If Click on login and validated then open the application.
Application.Run(new MdiForm());
else //If user click on close button on login windows just close the application
Application.Exit();
}
Further don't use Application.Exit() , on close button click event handler , it will be solve ur problem.
|
| Malik M.Shahid Saturday, July 25, 2009 11:43 AM |
i get the value of drResult as cancel instead of ok why is it so???? |
| harini_pavi Monday, August 17, 2009 9:32 AM |
Hi Harini,
Select the button on login Dialog form right click and choose proerty ,in the property window there is a propery name DialogResult contains multiple options set the option -- for cancel button 'Cancel' and OK button 'OK'
After that write click on dialog form and set the properties AcceptButton and CancelButton .
Good luck.
|
| Malik M.Shahid Monday, August 17, 2009 12:52 PM |
hey thanks :) i have another query like i have a parent form and many child forms . i wanna open a child form from another child form and it shud be opened within the same parent form and not in a seperate window .when i used formname.open() the form was opened as a seperate window but not within the MDI parent .can u just help me out with this.Thanks |
| harini_pavi Monday, August 31, 2009 4:07 AM |
Hi,
When first time application is loaded it is creating an object of MDIParent form, so when you try to open a child window through its menu you use this keyword to assign the child to MDIParent like this
MainForm childForm = new MainForm();
childForm.MdiParent = this;
childForm.Text = "Window " + childFormNumber++;
childForm.Show();
When you try to open a mdichild form from another child form , you should have a MDIParent form object so for this purpose you must define the static varible in MdiParent form.
public static MDIParent ParentMdiForm;
On initialize of MDIParent form assign the object , to the static variable.
public MDIParent()
{
InitializeComponent();
ParentMdiForm = this;
}
Now you are saved MDIParent form object to the static variable, you can open the Mdichild from child from by using the follwing code.
MDIChildFrom childForm = new MDIChildFrom();
childForm.MdiParent = MDIParent.ParentMdiForm; childForm.Text = "Window child form ";
childForm.Show();
Good Luck. |
| Malik M.Shahid Monday, August 31, 2009 9:31 AM |
hey gr8 !! it worked thanks a lot |
| harini_pavi Tuesday, September 01, 2009 5:31 AM |
i have 3 dropdownlists in one form .... on the first dropdownlist'sSelectedIndexChanged event the second dropdownlist is getting filled from the database and similarly the third dropdownlist is filled on second's SelectedIndexChanged event . Now in another form i am assigning values to those dropdownlists dropdownlist1.SelectedItem="1101"; dropdownlist2.SelectedItem="abc"; dropdownlist3.SelectedItem="123-34"; when i tracedthe program i found out tat the dropdownlist1.SelectedItem="1101" is invokingits respective SelectedIndexChanged event whereas the other two r not invoking why is it so ???
|
| harini_pavi Tuesday, September 01, 2009 11:04 AM |