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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OOP trouble with user control

Status
Not open for further replies.

silverspecv

Programmer
Oct 31, 2003
125
0
0
US
Ok, I have a form that has 3 strings, 3 buttons, and a user control. The buttons each instiantiate a new instance of the user control. The user control has a text box and an ok button. The idea is that the user types text in the box, clicks Ok, and the user control passes the text back to the form, and the form stuffs the data into the appropriate string variable. I did figure out how to raise an event from the user control and pass the text as an argument and the capture the text in the form's event handler. But what I can't figure out is how to feed a handle to the string into the user control during instantiation, and receive that handle back out in the event so that I can stuff the text into one of the 3 string values. I can't tell exactly what it's doing, but it looks like the text comes back and sets into local variables or something and the data never goes into the "global" string. Byval? Byref? I have no idea what I'm doing wrong. I general how would one accomplish this?
 
Nevermind, I got it.. since I use 3 instances of the user control, I need 3 event handlers. So since I already have 3 handlers, they all know which string to update..

bleh.. beat my head on it for hours, post a question, answer it myself 5 minutes later.. how typical =|
 

It's normal and a healthy sign, the process of trying to frame a problem in a concise question often means you have to step back a little and look at the 'big picture'. This in turn can give new insight if you've got stuck.

Full marks to everyone who follows up their own questions, so many times I've Googled a problem, found the exact problem described in a forum somewhere but with no clues to it's resolution. (Yes, I've done it myself and it usually means I didn't find the answer but found a totally different way to do the same thing - VB.NET's good for that).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top