reg. Inherited User Control

Sivi

New member
Joined
Sep 30, 2005
Messages
4
Programming Experience
1-3
Hi all,

I did create a user control which has Add, Mod and Del buttons.
I inherited the user control in one of my forms.
In the same form i have a tabpage control, and one of the pages have entry fields where user enters relevant values.

After entering the values, On selecting the Add button, the control goes to the class of Inheritied user control, where i have overrieden the button_click events of the base user control. Now how do i take the values from the form to this class.

Inside the form if i print form1.cmbAmount it prints me the correct value.
But in the inherited user control class, after importing the form class, i give

Dim objfrm as new myproject.myform
msgbox obhfrm.cmbAmount

This returns null. I can understand why it returns null. The scope of the control variable is lost. But cannot understand how to get the value of the form to this class.

Please help.
 
If you're creating a new instance of your class then it has no connection whatsoever to any existing instance and thus the value of any variable or property of the new instance is in no way related to the value of the same member in another instance. If they are two different objects then their members have different values, regardless of whether they are the same type or not.
 
Can this work?

Ok...
having a shared member variable in my form1 and storing the value in that variable will help me in any way?

Can that variable be accessed in my inherited user control after importing form1 class?
 
Original problem fixed but new one

Hi,Using shared variable has ofcourse solved my problem. But,I have an usercontrol and i have inherited that control. The inherited control has been pulled into the form. In my base class i have,Public overridable button1_click Public overridable button2_click Public overridable button3_click In my inherited class i havePublic overrides button1_click Public overrides button2_click Public overrides button3_click My implementation or the actual code is written under the inherited class events. On executing the code, the control first goes to the Public overrides button1_click , executes all the code.Then the control goes to the base class events, Public overridable button2_click , thenPublic overridable button3_click , thenPublic overridable button1_click , which again triggers Public overrides button1_click , and executes all the code again.So, twice the code is executed. Any solution for this?
 
Back
Top