CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: SendMessage?

  1. #1
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    170

    Question SendMessage?

    Hi all, what is the C# equivilent of SendMessage?

    right now I am doing it wrong like this:
    Code:
            private void Form1_Load(object sender, System.EventArgs e)
            {
                button1_Click( sender,  e);
            }
    But I would like to do something like this:
    Code:
            private void Form1_Load(object sender, System.EventArgs e)
            {
                SendMessage(button1.Click,sender,  e);
            }
    My reason for wanting to do a SendMessage is because I have multiple methods assigned to the Click event:
    Code:
                this.button1.Click += new System.EventHandler(this.ResetButtonColors);
                this.button1.Click += new System.EventHandler(this.XferPanelControls);
                this.button1.Click += new System.EventHandler(this.button1SpecificProcesses);
    It would be sloppy to call all of these event handlers directly from Form1_Load and everywhere else I need to fire off an event. It could get real ugly real fast.

    Thanks!

    Jim
    I am scifi

  2. #2
    Join Date
    Nov 2003
    Posts
    76
    Have you considered doing it something like this?
    Code:
    this.button1.Click += new System.EventHandler(Button1Click);
    //...
    void Button1Click (object sender, EventArgs e)
    {
    ThreeFunctions ();
    }
    
    void ThreeFunctions ()
    {
    ResetButtonColors ();
    XferPanelControls ();
    button1SpecificProcesses ();
    }
    
    private void Form1_Load(object sender, System.EventArgs e)
    {
    ThreeFunctions ();
    }
    It seems to better express your intent.

    I hope that helps!

  3. #3
    Join Date
    Nov 2003
    Posts
    76
    But if you're really, really determined to do it your way, consider this:
    http://www.syncfusion.com/FAQ/WinForms/FAQ_c92c.asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured