Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make a class (form) a variable

Status
Not open for further replies.

budjo

Programmer
Mar 4, 2004
19
PH
my situation is this ..

i have a item class , an entry form where you can add item , select category , subcategory etc ..

selecting a category will call lookup form (modal) form which contains all the pre-define category (which was added using a form) , the code to pass the selected category :

((Items)this.Owner).plookupcode = this.listbox1.selectedvalue)

//this.Owner equates to the form which calls the lookup ; Items

I casted the this.Owner to (Items) so that the value can be passed to the calling form ...

now the problem ..
I want to use the lookup form on other forms e.g. Search Items , but .. the code on the lookup form is hardcoded to cast the "this.Owner" to (Items) .. is there a way to put (Items) to a variable so that I can use the lookup form in any form like :

object CallingForm
CallingForm = Items;

then..
((CallingForm)this.Owner).plookupcode = this.listbox1.selectedvalue


thanks in advance ..
 
Declare an interface with one property called plookupcode and implement this property in all the calling forms.

Then you can write:

ICallingForm CallingForm;
CallingForm.plookupcode = this.listbox1.selectedvalue;
 
I see .. so the only way is to use interface .. I have to review how to use interface ..thanks .. hopefully i can make it work thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top