2 Replies - 493 Views - Last Post: 26 January 2013 - 08:31 AM Rate Topic: -----

#1 kristina1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 30-July 12

access a form's method from another form

Posted 26 January 2013 - 05:53 AM


i have a form which which loads some records in a grid view and a method which refresh these records. this form is called with the new operator each time.

i want to get from another form this refreshing method, how can i? i tried

but there is no effect as there can be opened more than one instance of form1 and the compilator dosen't know which form's method to access.

i would appreciate a lot any kind of help

Is This A Good Question/Topic? 0
  • +

Replies To: access a form's method from another form

#2 andrewsw  Icon User is offline

  • I'm not here to twist your niblets
  • member icon

Reputation: 4237
  • View blog
  • Posts: 15,470
  • Joined: 12-December 12

Re: access a form's method from another form

Posted 26 January 2013 - 08:27 AM

When you create an instance of the form you need to keep a reference to it.

Dim newForm1 As Form1 = New Form1
// then

So you need some way to make the variable available between the two forms, and to also handle the fact that you may have several instances of the same form.

However, this is not a good way to do this; cf. subscribing to form events. There are links and tutorials on this site.

This post has been edited by andrewsw: 26 January 2013 - 08:36 AM

Was This Post Helpful? 1
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5886
  • View blog
  • Posts: 12,826
  • Joined: 02-June 10

Re: access a form's method from another form

Posted 26 January 2013 - 08:31 AM


[*]Q: ...get Form/class 'A' to make a change or talk to Form/class 'B'

NOTE: Don't try to access GUI controls across forms. Its wrong. Nobody will hire you if you do this sort of crap. It violates every guideline for 'black box' programming, Separation of Responsibility, loose binding of components, and event driven programming. Read the tutorials and learn to do it right the first time so you don't develop bad habits that you just have to un-learn later.

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1