Click here to Skip to main content
15,913,487 members
Home / Discussions / C#
   

C#

 
AnswerRe: How could i develop a running-once application Pin
Dave Kreskowiak8-Sep-04 7:25
mveDave Kreskowiak8-Sep-04 7:25 
AnswerRe: How could i develop a running-once application Pin
Nick Parker8-Sep-04 9:57
protectorNick Parker8-Sep-04 9:57 
GeneralDrag and Drop Pin
eggie57-Sep-04 17:32
eggie57-Sep-04 17:32 
GeneralRe: Drag and Drop Pin
Corinna John7-Sep-04 19:53
Corinna John7-Sep-04 19:53 
GeneralRe: Drag and Drop Pin
eggie58-Sep-04 2:10
eggie58-Sep-04 2:10 
GeneralCustom Schedule Control Pin
Beringer7-Sep-04 15:57
Beringer7-Sep-04 15:57 
GeneralControl Pin
ImanMahmoud7-Sep-04 15:26
ImanMahmoud7-Sep-04 15:26 
GeneralRe: Control Pin
Charlie Williams7-Sep-04 15:53
Charlie Williams7-Sep-04 15:53 
In Form2.button1_Click you're creating a new instance of Form1, adding a Button to its panel1 control and... well, that's it. f1 is going the way of the dodo bird when the method exits.

What I think you're trying to do is add the Button to the instance of Form1 that called Form2.Show in the first place. You'll need a reference to that object in Form2. You can pass it in Form2's constructor or as a property. Here's an example:
public class Form2 : Form
{
   Form1 _form1;
   public Form2(Form1 form1)
   {
      _form1 = form1;
   }

   private void button1_Click(object sender, EventArgs e)
   {
      // create button as before
      _form1.panel1.Controls.Add(b);
   }

   // rest of class
}

public class Form1 : Form
{
   private void button2_Click(object sender, System.EventArgs e)
   {
      Form2 f2 = new Form2(this);
      f2.Show();
   }

   // rest of class
}



Charlie

if(!curlies){ return; }
GeneralRe: Control Pin
WillemM7-Sep-04 20:07
WillemM7-Sep-04 20:07 
GeneralFile association (open) Pin
Arun Bhalla7-Sep-04 14:29
Arun Bhalla7-Sep-04 14:29 
GeneralRe: File association (open) Pin
Sebastian Schneider8-Sep-04 2:07
Sebastian Schneider8-Sep-04 2:07 
GeneralCustom Control stacking (z-order) problem Pin
dotbomb7-Sep-04 11:59
dotbomb7-Sep-04 11:59 
GeneralRe: Custom Control stacking (z-order) problem Pin
leppie7-Sep-04 21:04
leppie7-Sep-04 21:04 
GeneralRe: Custom Control stacking (z-order) problem Pin
dotbomb11-Sep-04 16:43
dotbomb11-Sep-04 16:43 
GeneralRe: Custom Control stacking (z-order) problem Pin
dotbomb12-Sep-04 8:02
dotbomb12-Sep-04 8:02 
QuestionHow to use InternetQueryOption from WinInet in C# Pin
JavaWriter20047-Sep-04 10:09
JavaWriter20047-Sep-04 10:09 
AnswerRe: How to use InternetQueryOption from WinInet in C# Pin
David Salter7-Sep-04 11:16
David Salter7-Sep-04 11:16 
GeneralRe: How to use InternetQueryOption from WinInet in C# Pin
Anonymous7-Sep-04 11:48
Anonymous7-Sep-04 11:48 
General2d graphics with Direct3D 9 Pin
arik_a7-Sep-04 8:39
arik_a7-Sep-04 8:39 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 12:13
protectorChristian Graus7-Sep-04 12:13 
GeneralRe: 2d graphics with Direct3D 9 Pin
arik_a7-Sep-04 13:09
arik_a7-Sep-04 13:09 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 13:25
protectorChristian Graus7-Sep-04 13:25 
GeneralRe: 2d graphics with Direct3D 9 Pin
arik_a7-Sep-04 13:42
arik_a7-Sep-04 13:42 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 14:29
protectorChristian Graus7-Sep-04 14:29 
GeneralRe: 2d graphics with Direct3D 9 Pin
Judah Gabriel Himango7-Sep-04 14:34
sponsorJudah Gabriel Himango7-Sep-04 14:34 

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.