Click here to Skip to main content
16,006,442 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: C# calling forms Pin
Luc Pattyn7-Mar-08 14:43
sitebuilderLuc Pattyn7-Mar-08 14:43 
GeneralRe: C# calling forms Pin
Paul Conrad7-Mar-08 14:47
professionalPaul Conrad7-Mar-08 14:47 
GeneralRe: C# calling forms Pin
Pete O'Hanlon9-Mar-08 10:50
mvePete O'Hanlon9-Mar-08 10:50 
GeneralRe: C# calling forms Pin
Paul Conrad9-Mar-08 11:00
professionalPaul Conrad9-Mar-08 11:00 
GeneralRe: C# calling forms Pin
Christian Graus7-Mar-08 23:10
protectorChristian Graus7-Mar-08 23:10 
GeneralRe: C# calling forms Pin
PRACTICE7-Mar-08 18:49
PRACTICE7-Mar-08 18:49 
GeneralRe: C# calling forms Pin
Christian Graus8-Mar-08 10:58
protectorChristian Graus8-Mar-08 10:58 
GeneralRe: C# calling forms Pin
Pete O'Hanlon7-Mar-08 9:09
mvePete O'Hanlon7-Mar-08 9:09 
I'm going to suggest that you use one of the design patterns here. One that I'm thinking might help is the Mediator pattern (have a look on Google to find it), but it basically looks like this:
public class Mediator
{
  private Form1 _loginForm;
  private Form2 _buddyForm;

  public Form2 BuddyForm
  {
    get 
    { 
      if (_buddyForm == null)
        _buddyForm = new Form2(this);
       return _buddyForm;
    }
  }
  public Form1 LoginForm
  {
    get 
    {
      if (_loginForm == null)
        _loginForm = new Form1(this);
      return _loginForm;
    }
  }

  public void Logout()
  {
    LoginForm.Show();
    BuddyForm.Hide();
  }
  // You get the idea for the rest anyway...
}

public class Form1 : Form
{
  private Mediator _mediator;
  public Form1(Mediator mediator)
  {
    _mediator = mediator;
  }

  // Some code to respond to a button for instance
  protected virtual void Login_Click(object sender, EventArgs e)
  {
    _mediator.ShowBuddy();
  }
}

public class Form2 : Form
{
  private Mediator _mediator;
  public Form2(Mediator mediator)
  {
    _mediator = mediator;
  }

  // Some code to respond to a button for instance
  protected virtual void Logout_Click(object sender, EventArgs e)
  {
    _mediator.Logout();
  }
}



Deja View - the feeling that you've seen this post before.

My blog | My articles



GeneralRe: C# calling forms Pin
Gregory Bryant7-Mar-08 12:22
Gregory Bryant7-Mar-08 12:22 
GeneralRe: C# calling forms Pin
Paul Conrad7-Mar-08 14:49
professionalPaul Conrad7-Mar-08 14:49 
GeneralRe: C# calling forms Pin
Christian Graus7-Mar-08 23:14
protectorChristian Graus7-Mar-08 23:14 
GeneralRe: C# calling forms Pin
Pete O'Hanlon8-Mar-08 3:23
mvePete O'Hanlon8-Mar-08 3:23 
JokeRe: C# calling forms Pin
Christian Graus8-Mar-08 11:29
protectorChristian Graus8-Mar-08 11:29 
GeneralRe: C# calling forms Pin
Pete O'Hanlon9-Mar-08 10:48
mvePete O'Hanlon9-Mar-08 10:48 
QuestionCenter align items in combo box Pin
Bala Thirumalai6-Mar-08 20:15
Bala Thirumalai6-Mar-08 20:15 
GeneralRe: Center align items in combo box Pin
led mike7-Mar-08 4:45
led mike7-Mar-08 4:45 
GeneralRe: Center align items in combo box Pin
Gregory Bryant7-Mar-08 6:59
Gregory Bryant7-Mar-08 6:59 
GeneralRe: Center align items in combo box [modified] Pin
Bala Thirumalai7-Mar-08 15:44
Bala Thirumalai7-Mar-08 15:44 
GeneralUse Security Trimming on a WinForm... Pin
Illegal Operation6-Mar-08 1:19
Illegal Operation6-Mar-08 1:19 
GeneralRe: Use Security Trimming on a WinForm... Pin
led mike6-Mar-08 4:56
led mike6-Mar-08 4:56 
GeneralRe: Use Security Trimming on a WinForm... Pin
Pete O'Hanlon6-Mar-08 10:04
mvePete O'Hanlon6-Mar-08 10:04 
QuestionGlobally detect windows context menu popup [modified] Pin
AndrewVos4-Mar-08 1:00
AndrewVos4-Mar-08 1:00 
GeneralRe: Globally detect windows context menu popup Pin
Giorgi Dalakishvili4-Mar-08 1:26
mentorGiorgi Dalakishvili4-Mar-08 1:26 
GeneralRe: Globally detect windows context menu popup Pin
AndrewVos5-Mar-08 22:52
AndrewVos5-Mar-08 22:52 
Generalhelp needed in deploying windows application Pin
Sadaf Naeem3-Mar-08 22:30
Sadaf Naeem3-Mar-08 22:30 

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.