Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling Public Function form other form

Posted on 2006-11-29
3
Medium Priority
?
149 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
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 80 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

876 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