By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

accessing data from a class event in a form

P: n/a
I have a multiproject solution; one of the projects is a group of classes
doing data massage and insertions. One of the other projects is a UI that
kicks off the process in certain situations. I'd my UI to be able to read
properties or events or whatever it takes so the UI can display messages
about what's happening in the data project. However I can't find any
documentation on how to do this. Can someone please point me in the right
direction? TIA.
--
glen
Nov 9 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
It depends on where you instantiate instances of your classes. If it's in
the UI, then you can put events in your classes and handle them in your UI
thread. There are many ways to do this.
--
Dennis in Houston
"glen" wrote:
I have a multiproject solution; one of the projects is a group of classes
doing data massage and insertions. One of the other projects is a UI that
kicks off the process in certain situations. I'd my UI to be able to read
properties or events or whatever it takes so the UI can display messages
about what's happening in the data project. However I can't find any
documentation on how to do this. Can someone please point me in the right
direction? TIA.
--
glen
Nov 9 '06 #2

P: n/a
I thought it might be something along these lines. Sounds like your saying I
need event handlers in the UI code to capture the output of class events. Can
you point me at some good examples? TIA.
--
glen
"Dennis" wrote:
It depends on where you instantiate instances of your classes. If it's in
the UI, then you can put events in your classes and handle them in your UI
thread. There are many ways to do this.
--
Dennis in Houston
"glen" wrote:
I have a multiproject solution; one of the projects is a group of classes
doing data massage and insertions. One of the other projects is a UI that
kicks off the process in certain situations. I'd my UI to be able to read
properties or events or whatever it takes so the UI can display messages
about what's happening in the data project. However I can't find any
documentation on how to do this. Can someone please point me in the right
direction? TIA.
--
glen
Nov 10 '06 #3

P: n/a
Never mind I figured it out. For the benefit of others here is my code.

In the declarations area of one of my classes I inserted the following:
Public Event UIData(ByVal text As String)

In one of the class functions do some processing and want to send a message
to the UI so inserted the following:
RaiseEvent UIData("Successful File Read. Record count of " & CStr(rcount) &
". Database Insert commencing....")

Next, in the load event of the form I did the following:
AddHandler processor.UIData, AddressOf DataHandler - to watch for the output
of a raised event in my class.

Finally I added a sub() to insert the data to a list box:
Public Sub DataHandler(ByVal data As String)
lstEvents.Items.Add(data)
End Sub
--
glen
"Dennis" wrote:
It depends on where you instantiate instances of your classes. If it's in
the UI, then you can put events in your classes and handle them in your UI
thread. There are many ways to do this.
--
Dennis in Houston
"glen" wrote:
I have a multiproject solution; one of the projects is a group of classes
doing data massage and insertions. One of the other projects is a UI that
kicks off the process in certain situations. I'd my UI to be able to read
properties or events or whatever it takes so the UI can display messages
about what's happening in the data project. However I can't find any
documentation on how to do this. Can someone please point me in the right
direction? TIA.
--
glen
Nov 10 '06 #4

P: n/a
That's it! You can also setup to access procedures and properties of the
form class in the classes setting a property in the Class to the Form or pass
the Form as a variable in the New procedure of the Class. Then in the Class,
you can call procedures/properties in the Form class.

Anyway, sounds like you are off and running until the next problem arises.
Good Luck.
--
Dennis in Houston
"glen" wrote:
Never mind I figured it out. For the benefit of others here is my code.

In the declarations area of one of my classes I inserted the following:
Public Event UIData(ByVal text As String)

In one of the class functions do some processing and want to send a message
to the UI so inserted the following:
RaiseEvent UIData("Successful File Read. Record count of " & CStr(rcount) &
". Database Insert commencing....")

Next, in the load event of the form I did the following:
AddHandler processor.UIData, AddressOf DataHandler - to watch for the output
of a raised event in my class.

Finally I added a sub() to insert the data to a list box:
Public Sub DataHandler(ByVal data As String)
lstEvents.Items.Add(data)
End Sub
--
glen
"Dennis" wrote:
It depends on where you instantiate instances of your classes. If it's in
the UI, then you can put events in your classes and handle them in your UI
thread. There are many ways to do this.
--
Dennis in Houston
"glen" wrote:
I have a multiproject solution; one of the projects is a group of classes
doing data massage and insertions. One of the other projects is a UI that
kicks off the process in certain situations. I'd my UI to be able to read
properties or events or whatever it takes so the UI can display messages
about what's happening in the data project. However I can't find any
documentation on how to do this. Can someone please point me in the right
direction? TIA.
--
glen
Nov 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.