Solved

Calling Public Function form other form

Posted on 2006-11-29
3
143 Views
Last Modified: 2010-04-23
Hi,

   I am having two forms say FormA and FormB, FormA is having Listview and a Public Function say LoadData, to fill ListView with data, I called this function from Form_Load_Event of FormA which load the ListView with data without problem but if I call this Function form FormB it does not do any thing.

I call this function from FormB in following manner:

Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click

     Dim FrmC as New FormA

      FrmC.LoadData()
End Sub


Thanx
0
Comment
Question by:bobbyamor
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 20 total points
ID: 18037828
Right....because you have created a NEW instance of FormA and called its function.  You need a reference to the actual FormA instance that is on your screen.

You need to pass a reference to FormA into FormB when you create it.

Or if you have VB.Net 2005, you can iterate the forms collection to find the right one.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question