S
Steve
I have a .NET windows program that has a VB.NET component and a C#
component. The VB component contains the form and handles all the UI stuff.
The C# component drives the engine that actually does all the work.
The VB component has one form called frmX. On frmX are three text boxes
(txtA, txtB, txtC) and a button (cmdAdd). When the button is clicked, the
program is supposed to add the values in txtA and txtB and display it in
txtC.
The cmdAdd_Click event instantiates a C# object called Add. I want to pass
in frmX and have the C# object extract the values in txtA and txtB and do
the calculation.
If I pass in just the text boxes then I can declare the parameters in the C#
class using
Public int DoAdd(System.Windows.Forms.TextBox txtA,
System.Windows.Forms.TextBox txtB)
But that is not what I want to do. Obviously this is only a test case and
the actually program needs to access all the elements on the form.
The question I have is, how do I pass in frmX and have access to all the
elements (text boxes, drop downs, etc.)? If I declare the parameter in C#
as
Public int DoAdd(System.Windows.Forms.Form frmF)
I have access to all the properties and method of a form, but not the
specific elements in frmX. The C# method has no clue about frmX. I have a
feeling it has to do with somehow getting a reference in the C# project or
somehow casting frmF to frmX
Any suggestions?
Thanks.
component. The VB component contains the form and handles all the UI stuff.
The C# component drives the engine that actually does all the work.
The VB component has one form called frmX. On frmX are three text boxes
(txtA, txtB, txtC) and a button (cmdAdd). When the button is clicked, the
program is supposed to add the values in txtA and txtB and display it in
txtC.
The cmdAdd_Click event instantiates a C# object called Add. I want to pass
in frmX and have the C# object extract the values in txtA and txtB and do
the calculation.
If I pass in just the text boxes then I can declare the parameters in the C#
class using
Public int DoAdd(System.Windows.Forms.TextBox txtA,
System.Windows.Forms.TextBox txtB)
But that is not what I want to do. Obviously this is only a test case and
the actually program needs to access all the elements on the form.
The question I have is, how do I pass in frmX and have access to all the
elements (text boxes, drop downs, etc.)? If I declare the parameter in C#
as
Public int DoAdd(System.Windows.Forms.Form frmF)
I have access to all the properties and method of a form, but not the
specific elements in frmX. The C# method has no clue about frmX. I have a
feeling it has to do with somehow getting a reference in the C# project or
somehow casting frmF to frmX
Any suggestions?
Thanks.