473,811 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I access a WindowForm element from a Class function?

pod
298 Contributor
I work in MS Visual Studio 2008, I have a VB.NET Solution which has three Projects, BusinessObjectL ibrary (object properties), DataAccessLibra ry (object functions such as selectAll, exportToExcel) and WindowUserInter face (UserForms c/w Controls)


In my WindowUserInter face (project) I have a form called "rolFormGrid.vb ", on this form, I have a DataGrid that gets filled with a function called "selectAll" when the form is loaded, I also have a button that calls the function "exportToEx cel" and I have a Progress Bar called "rolProgressBar " ***.

In my DataAccessLibra y (project) I have a class called "ROL_Adapter.vb ", and in this class resides the function called "exportToEx cel" which has all the code to create an Excel Workbook. When this function is being called, it can takes close to a minute to export to excel. We all know how users can be impatient if they do not see anything happening in the foreground when an application is working, that is the reason I want the progress bar.

I want to access this progressbar from my code in my "exportToEx cel" function.

How do I do this?

In MS Access I would call Form_FormName.P rogressBar but I cannot find the way in VB.NET to address the Form

Can you help me?

I hope my explanation is good enough
Sep 8 '10 #1
3 2003
Aimee Bailey
197 Recognized Expert New Member
The easiest way to do this would be to use events, have a set of events on the class that is executing code that raises an event when something happens, and have your form listen for it. when the event is fired, the form can respond by updating the progress bar.

Hope this helps

Aimee.
Sep 8 '10 #2
pod
298 Contributor
thanks Aimee for taking a peek at my problem.
I need to clarify a bit more my problem, the best way I can think of is by comparison with MS Access development in VBA. I hope you are familiar with this.

When developing in VBA we have MS Office Access Class Objects and Modules.

I tend to put all of my functions in modules. In my functions, if I want to change a caption on a form, I can address the form this way

Expand|Select|Wrap|Line Numbers
  1. Form_myForm1.Label1.Caption = "this is my label"
  2.  
As soon as I type "Form_myFor m1" and put a dot, all of my form elements appear in context.

On my VB.NET I can address the form element from the form code side just by typing "Me." but I am unable to do this in my function which is in project "ROL_Adapte r"

I suppose I must Import or Reference something but I do not know what...
Sep 9 '10 #3
pod
298 Contributor
found my answer. It was a matter of adding a System.Windows. Forms reference to the "DataAccessLibr ary" Project and to change the Access Modifier of the ProgressBar to "Public"

May this post save time to others
Sep 13 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1272
by: kanedatakeshi | last post by:
Hi folks! The problem is the following: I use Python 2.1 embedded in a C++ game engine. Some of the engines complexer objects (AI, game logic, etc.) use python classes that act as an extension of those "parent" C++-classes. The python classes are currently loaded on demand by their "parent" C++-instances, say if an enemy gets activated and starts running. I do
4
4646
by: Dennis C. Drumm | last post by:
Is there a way with C# to allow one class access to a method or field of another class, without making that method or field visible to all other classes, as would be the case when making the method or field public? Thanks, Dennis
6
2630
by: marco_segurini | last post by:
Hi, the following sample code shows a compiler error I get trying to build some old code with the last CL compiler (vers 13.10.3077): //----- begin #include <iostream> namespace ns {
6
6893
by: Allerdyce.John | last post by:
Hi, How can I Random access an element in a STL List if I have a pointer to that list? I know how to do that if I have a reference to a STL list, but how can I do that if I have a pointer to a STL List. void function (vector<int>& myLIst) { // access the first element of myList printf ("%d", myList);
9
1863
by: MariusI | last post by:
Consider the following class layout public class Order { public ProductOrder AddProductOrder(/* variables required to create a product order */) { /* Check if the product order can be added to the order */ }
1
4224
by: SoxFan44 | last post by:
Hi, I have a DataGridView on my Form1 and a public function that can add a row to it. I want to be able to access that member function from another class. I'm confused as to how to do this. Can anyone please help? Thanks!
2
4165
by: rajasekaranrajasekaran | last post by:
hi,,, i am having a scenario plz help me to find a soln,, its really challenging for me hope it is useful 4 u 2.... I need to access a private member function witout using a friend, virtual and not modifying the class,, for example consided this class X { private: void show() // this is the fn i need to access public:
6
4141
by: Rick | last post by:
Hi, Can anyone explain to me why the below fails to compile - seeing otherA->f(); as a call to a inaccessible function, while otherB->f(); is ok? It seems you can happily access protected functions of another (same type) - but not via a base class pointer.... I've checked the FAQs, Meyers etc but nothing obvious I can find explains it.
5
10474
by: Mel | last post by:
I need to access an element of my top window from inside an IFrame within that window. I tried: parent.MYFRAME.document.getElementById("LHS"); and i get a "Access Denied" is there a way to do this ?
4
14422
by: Javier | last post by:
Hello, is this possible? I have a pure virtual function in the base class (to force the programmers of the derived classes to have this function implemented) but I want to call the derived class function from a base class reference: class A { public: virtual void function() = 0;
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.