473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

VB HELP: Sharing A Variable From Win Application To Dynamically Added Control

I have an application and use custom user controls as plugins. Is there any
way to communicate back and forth from control to app. NOTE: The control is
not refrenced in the app, it will act as a plugin and will be dynamically
loaded to the app.

Example:

1. My application as a public variable
2. The control must receieve the value of the public variable
3. The control will do some math and encryption of the variable
4. The control will return the value to the main application
5. The application will display the results

Any help on how to communicate back and forth with the dynamically created
control will be greatly appreciated!

Thanks,

Dan
Nov 21 '05 #1
3 1070
"Daniel Friend" <da*@donotspam.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
I have an application and use custom user controls as plugins.
Is there any way to communicate back and forth from control
to app. NOTE: The control is not referenced in the app


I'd do it this way:

Every Plug-In implements this Interface:

Public Interface IPlugIn
WriteOnly Property ParentForm as IPlugInContainer
' Any other properties/methods that the main application
' might ask /every/ plug-in to do.
End Interface

Have the main application implement this Interface:

Public Interface IPlugInContainer
' Include any properties/methods that a Plug-In might need.
' /Don't/ rely on properties that /happen/ to be on the Form
End Interface

Both of these exist in an assembly common to both the application
and the plug-ins. They form a well-defined communication channel
between plug-in and application; a common currency that the two
can "converse" in.

As you load [each] plug-in into your application, assign the Form
to the [IPlugIn].ParentForm property (you *know* it's there
because the plug-in, whatever /else/ it does, implements the Interface),
as in

' Get Plug-In object
oLoadedPlugIn = Activator.CreateInstance( ...

' Pass the parent application [form] reference to the plug-in
DirectCast( oLoadedPlugIn, IPlugIn ).ParentForm _
= DirectCast( Me, IPlugInContainer )

Your plug-in can now access anything in the IPlugInContainer
Interface (which, of course, calls methods in the main application).

HTH,
Phill W.
Nov 21 '05 #2
If the control is created by the application can you create it based off of
MustInherit class?

Public MustInherit Class DynControl

Public ReadOnly Property MyCalulations () as Object (or whatever)

Public Event ImDoneCalculating (ByVal sender As Object, e as
System.EventArgs)

.......

Private sub Calc
....
RaiseEvent ImDoneCalculating (me, System.EventArgs.Empty)
End Sub

End Class
Public Class MyApp
Private Sub CreateDynControl

Dim MyControl as New DynControl
AddHandler MyControl.ImDoneCalculating , AddressOf Handle_ImDone

End Sub

Private Sub Handle_ImDone (ByVal sender As Object, e as
System.EventArgs)

Dim objValue as Object (or whatever)
objValue = sender.MyCalculations

End Sub

End Class
"Daniel Friend" <da*@donotspam.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
I have an application and use custom user controls as plugins. Is there
any
way to communicate back and forth from control to app. NOTE: The control
is
not refrenced in the app, it will act as a plugin and will be dynamically
loaded to the app.

Example:

1. My application as a public variable
2. The control must receieve the value of the public variable
3. The control will do some math and encryption of the variable
4. The control will return the value to the main application
5. The application will display the results

Any help on how to communicate back and forth with the dynamically created
control will be greatly appreciated!

Thanks,

Dan

Nov 21 '05 #3
Actually, scratch my answer.

I was in the middle of doing what I told you to do, and just skimmed over
your question, so it seemed right at the time. But thinking about it for a
sec...

1. What exactly are you dynamically creating? How do you 'on the fly'
create a control to do math calcs?
2. My syntax is off on the CreateDynControl, we can get back to that.
3. I skipped over #2 of your explination, so it has nothing to do w/ your
problem.

How are you creating this control? And what exactly do you mean by dynamic?
If your doing math and encryption it seems like your using a precreated
class / .dll and just calling it at run time?


"Eric Dreksler" <ericd AT accessoneinc DOT com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
If the control is created by the application can you create it based off
of MustInherit class?

Public MustInherit Class DynControl

Public ReadOnly Property MyCalulations () as Object (or whatever)

Public Event ImDoneCalculating (ByVal sender As Object, e as
System.EventArgs)

......

Private sub Calc
....
RaiseEvent ImDoneCalculating (me, System.EventArgs.Empty)
End Sub

End Class
Public Class MyApp
Private Sub CreateDynControl

Dim MyControl as New DynControl
AddHandler MyControl.ImDoneCalculating , AddressOf Handle_ImDone

End Sub

Private Sub Handle_ImDone (ByVal sender As Object, e as
System.EventArgs)

Dim objValue as Object (or whatever)
objValue = sender.MyCalculations

End Sub

End Class
"Daniel Friend" <da*@donotspam.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
I have an application and use custom user controls as plugins. Is there
any
way to communicate back and forth from control to app. NOTE: The control
is
not refrenced in the app, it will act as a plugin and will be dynamically
loaded to the app.

Example:

1. My application as a public variable
2. The control must receieve the value of the public variable
3. The control will do some math and encryption of the variable
4. The control will return the value to the main application
5. The application will display the results

Any help on how to communicate back and forth with the dynamically
created
control will be greatly appreciated!

Thanks,

Dan


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
2
by: intrepid_dw | last post by:
All I am writing a C# WinForms application which is giving me some problems. The application consists of a form containing an empty Tab control to which TabPages are added dynamically (at...
5
by: =?Utf-8?B?U2FsYW1FbGlhcw==?= | last post by:
Hi, I have a user control which I like to use in several projects (winforms) in the same solution. Inside lets say Winapp1 , When adding a reference to this control, I can dynamically or statically...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.