.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Windows application Form Focus in C#.NET

Posted By: Sunil     Posted Date: September 02, 2008    Points:2   Category :Windows Application
How to get focus on which form those are already Opened.

When we click on Menubar if that related link already opened then not open New form, Example if we working with 4 form and right now we opened three form, currently i am working on form3 and that time if i click on menu item from1 then it not open new one its just get up on form3.

Responses
Author: Shashi Ray             
Posted Date: September 02, 2008     Points: 5   

use Response.Redirect("Form1.aspx?");

Shashi Kant Ray
Author: Sunil             
Posted Date: September 02, 2008     Points: 5   

dear this is not a web application.

Author: Sunil             
Posted Date: September 02, 2008     Points: 5   

How to get focus on which form those are already Opened.

When we click on Menubar if that related link already opened then not open New form, Example if we working with 4 form and right now we opened three form, currently i am working on form3 and that time if i click on menu item from1 then it not open new one its just get up on form3.

Author: Sunil             
Posted Date: September 02, 2008     Points: 5   

Please Suggest in WINDOWS APPLICAtion with C#.NET

Author: Pankaj Mishra             
Posted Date: September 02, 2008     Points: 5   

Hi Sunil,
Its tricky Try like this. Declare global variable at class level for all the forms that you have in menu for eg.


Form1 form1 = null;
Form2 form2 = null;
.........


Now In the menu click or button click
try like this

private void button1_Click(object sender, EventArgs e)
{
if (form1 == null)
{
form1 = new Form1();
form1.FormClosed += SetFormToNull; //Raise event
form1.Show(this); // SHow form
}
form1.Focus();
}

Event method

private void SetFormToNull(object sender, EventArgs e)
{
form1 = null; //set null when closed
}


Hope this will help you

Cheers
Pankaj

Author: Sunil             
Posted Date: September 03, 2008     Points: 5   

Thank you : Pankaj Mishra your code is working.

Author: Santosh             
Posted Date: October 08, 2009     Points: 5   

hi

please follow the below link,i think it will solve your problem.

http://www.dotnetspark.com/kb/Content.aspx?id=900

Ragards
Santosh
http://santoshdotnetarena.blogspot.com/

Author: Clintonzz             
Posted Date: April 02, 2014     Points: 20   

You may have a study on some WinForms UI Form control:

http://www.kettic.com/winforms_ui/csharp_guide/forms_dialogs_forms.shtml



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend