Click here to Skip to main content
15,908,013 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to pass reference Pin
sysrev8-Feb-07 0:39
sysrev8-Feb-07 0:39 
Questionform.close() not working Pin
red60mans7-Feb-07 14:13
red60mans7-Feb-07 14:13 
AnswerRe: form.close() not working Pin
Christian Graus7-Feb-07 14:33
protectorChristian Graus7-Feb-07 14:33 
GeneralRe: form.close() not working Pin
red60mans7-Feb-07 14:58
red60mans7-Feb-07 14:58 
GeneralRe: form.close() not working Pin
Luc Pattyn7-Feb-07 15:04
sitebuilderLuc Pattyn7-Feb-07 15:04 
GeneralRe: form.close() not working Pin
Christian Graus7-Feb-07 15:14
protectorChristian Graus7-Feb-07 15:14 
GeneralRe: form.close() not working Pin
Christian Graus7-Feb-07 15:15
protectorChristian Graus7-Feb-07 15:15 
QuestionRe: form.close() not working Pin
red60mans7-Feb-07 17:24
red60mans7-Feb-07 17:24 
i am a newbie so bear with me.

Form1::

public void Bttn_Click(object sender, EventArgs e)
{
Form2 r = new Form2();
r.Show();
this.Hide();
}

This works fine for this form ie Form1
as u have said that it is not necessary to create one more instance of Form1 and rather use this.hide().


but i have one more event in Form2 called Form2Button_click event where i need to hide form2 and show Form1. Now if i create a Form1 instance as shown below i will have two instances of Form1. One which was hidden using previous code and Second instance in the Form2 button click event.

public Form2Button_click(object sender, EventArgs e)
{
Form1 newInstanceForm1 = new Form1();
newInstanceForm1 .Show();
this.Hide();
}


1)How do i access Form1 from Form2 without creating a new instance of Form1??
or how do i get hold of the original Form1 instance from Form2

2)You have also said that it is better to create two Forms as controls......where do i create those controls??
i have only two forms Form1 being the main form. So do i need to create these forms as controls in main()??

i am just confused

Any help is appreciated,



yojimbo
AnswerRe: form.close() not working Pin
ShermansLagoon7-Feb-07 21:00
ShermansLagoon7-Feb-07 21:00 
AnswerRe: form.close() not working Pin
Christian Graus7-Feb-07 21:09
protectorChristian Graus7-Feb-07 21:09 
QuestionSpace Elevator Problem Pin
Member 38066887-Feb-07 13:34
Member 38066887-Feb-07 13:34 
AnswerRe: Space Elevator Problem Pin
Dave Kreskowiak7-Feb-07 14:09
mveDave Kreskowiak7-Feb-07 14:09 
AnswerRe: Space Elevator Problem [modified] Pin
Not Active7-Feb-07 14:11
mentorNot Active7-Feb-07 14:11 
GeneralRe: Space Elevator Problem Pin
Christian Graus7-Feb-07 14:16
protectorChristian Graus7-Feb-07 14:16 
GeneralRe: Space Elevator Problem Pin
Not Active7-Feb-07 14:23
mentorNot Active7-Feb-07 14:23 
AnswerRe: Space Elevator Problem Pin
Christian Graus7-Feb-07 14:15
protectorChristian Graus7-Feb-07 14:15 
QuestionLeave event not firing Pin
kumar.bs7-Feb-07 13:32
kumar.bs7-Feb-07 13:32 
AnswerRe: Leave event not firing Pin
Dave Kreskowiak7-Feb-07 14:05
mveDave Kreskowiak7-Feb-07 14:05 
GeneralRe: Leave event not firing Pin
kumar.bs7-Feb-07 14:27
kumar.bs7-Feb-07 14:27 
QuestionListbox Help Pin
Saamir7-Feb-07 12:07
Saamir7-Feb-07 12:07 
QuestionDeep copy and shallow copy with List<> [modified] Pin
jeffb427-Feb-07 10:51
jeffb427-Feb-07 10:51 
QuestionCheck for an existing item in a treeview Pin
sharpiesharpie7-Feb-07 9:43
sharpiesharpie7-Feb-07 9:43 
AnswerRe: Check for an existing item in a treeview Pin
led mike7-Feb-07 9:48
led mike7-Feb-07 9:48 
GeneralRe: Check for an existing item in a treeview Pin
sharpiesharpie7-Feb-07 9:51
sharpiesharpie7-Feb-07 9:51 
AnswerRe: Check for an existing item in a treeview Pin
PIEBALDconsult7-Feb-07 10:00
mvePIEBALDconsult7-Feb-07 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.