Raising click event on another form - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Raising click event on another form

QuaggaQuagga Posts: 3Member
I'm very new to VB.net and having a lot of trouble raising a click event on another form. I've got two forms (form1 & form2). Form1 has a button that shows (or opens) form2 with the following code:
Dim newform2 As New Form2
newform2.ShowDialog(Me)
Now I have a button on form2 that is supposed to close itself (form2) and raise the click event of button (btnCancel) on form1 that will clear all the textboxes (of form1) and do some other form houskeeping to get form1 back to its original state.
I've tried the folowing code but the "form1.btnCancel" bit produces a "Reference to a non-shared member requires an object refrence" error.
Form1.btnCancel.performclick()

I'm using VB.NET Version 2003 and ANY help will be highly appreciated!

Comments

  • btsebbtseb Posts: 67Member
    : I'm very new to VB.net and having a lot of trouble raising a click event on another form. I've got two forms (form1 & form2). Form1 has a button that shows (or opens) form2 with the following code:
    : Dim newform2 As New Form2
    : newform2.ShowDialog(Me)
    : Now I have a button on form2 that is supposed to close itself (form2) and raise the click event of button (btnCancel) on form1 that will clear all the textboxes (of form1) and do some other form houskeeping to get form1 back to its original state.
    : I've tried the folowing code but the "form1.btnCancel" bit produces a "Reference to a non-shared member requires an object refrence" error.
    : Form1.btnCancel.performclick()
    :
    : I'm using VB.NET Version 2003 and ANY help will be highly appreciated!
    :
    :
    [red]*********************************************[/red]
    I was just reading an article on this very topic. I think it should provide you with all that you need. It is entitled [blue]"Multiple Forms in VB .NET Part 2 - Accessing Controls on Other Forms"[/blue]

    http://www.devcity.net/net/printable_article.aspx?cid=6&y=2003&m=7&d=23
  • QuaggaQuagga Posts: 3Member
    : : I'm very new to VB.net and having a lot of trouble raising a click event on another form. I've got two forms (form1 & form2). Form1 has a button that shows (or opens) form2 with the following code:
    : : Dim newform2 As New Form2
    : : newform2.ShowDialog(Me)
    : : Now I have a button on form2 that is supposed to close itself (form2) and raise the click event of button (btnCancel) on form1 that will clear all the textboxes (of form1) and do some other form houskeeping to get form1 back to its original state.
    : : I've tried the folowing code but the "form1.btnCancel" bit produces a "Reference to a non-shared member requires an object refrence" error.
    : : Form1.btnCancel.performclick()
    : :
    : : I'm using VB.NET Version 2003 and ANY help will be highly appreciated!
    : :
    : :
    : [red]*********************************************[/red]
    : I was just reading an article on this very topic. I think it should provide you with all that you need. It is entitled [blue]"Multiple Forms in VB .NET Part 2 - Accessing Controls on Other Forms"[/blue]
    :
    : http://www.devcity.net/net/printable_article.aspx?cid=6&y=2003&m=7&d=23
    :

    ************************************
    Thank you very much. Its the OOP that gave me some trouble. Thanks again.

Sign In or Register to comment.