InvokeOnClick Method in VS2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Umlja1NlYW4=?=

    InvokeOnClick Method in VS2005

    I have a main form frmMain containing a button button1

    I have another form frmNew containing a textbox txtBox1 and a button button2.

    I have the following code behind the button button2 in frmNew:
    Messagebox.Show (txtBox2.Text.t ostring());

    I have the following code behind the button button1 in frmMain:
    frmMain frm = new frmNew();
    Button btn = frm.button2;
    this.InvokeOnCl ick(btn, EventArgs.Empty );

    When application is launched; both forms a re displayed on the screen. I
    entered a "My Text Message" in the frmNew's textbox txtBox1 and then went to
    frmMain and clicked the button button1 which invoked the click event on
    frmNext to display the message box

    The code above displays the messagebox but it is blank; it should display
    "John Doe" but doesn't. Please help!!!
  • Pavel Minaev

    #2
    Re: InvokeOnClick Method in VS2005



    RickSean wrote:
    I have a main form frmMain containing a button button1
    >
    I have another form frmNew containing a textbox txtBox1 and a button button2.
    >
    I have the following code behind the button button2 in frmNew:
    Messagebox.Show (txtBox2.Text.t ostring());
    >
    I have the following code behind the button button1 in frmMain:
    frmMain frm = new frmNew();
    Button btn = frm.button2;
    this.InvokeOnCl ick(btn, EventArgs.Empty );
    >
    When application is launched; both forms a re displayed on the screen. I
    entered a "My Text Message" in the frmNew's textbox txtBox1 and then went to
    frmMain and clicked the button button1 which invoked the click event on
    frmNext to display the message box
    >
    The code above displays the messagebox but it is blank; it should display
    "John Doe" but doesn't. Please help!!!
    The documentation on InvokeOnClick seems pretty scarce, but it's
    rather telling that it's not a static method. I would not be surprised
    if you'd have to call it either on the control itself (though then
    it's not clear why you have to pass "toInvoke" argument, which would
    be the same thing), on its container, or on the form which contains
    it.

    Comment

    Working...