|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
User Controls basic questionHi,
Say I wanted to store a variable on my main form, then display it, or react to it, on a User Control I'd made. How would I go about getting the variable from my main form to the User Control? Perhaps I want to put this variable in a textbox on the User Control and send the data back to the main form when the user changes it. How would I get the message of the change back to the main form? Sorry if these are strange or hilariously basic questions, but the book I'm using doesn't really deal with User Controls, so I have to ask here. KristianFrost A usercontrol can have a property, which is:-
Private MyString as String Public Property MyProperty() as String Get Return myString End Get Set(byval Value as String) myString=Value End Set End Property or you could have Public Sub ChangeMyString(byval value as string) mtString=value End Sub then to return the string Public Event ReturnString(byval value as string) and in the textxchanged event RaiseEvent ReturnString(mystring) Heh.
When I read that, I thought you were giving me a silly answer. Turns out that, deciding that you were giving me a serious answer, and = then deciding that your way was the accepted way of accessing User = Controls, I had enough information for to work the other mysteries of Us= er = Controls I had been having trouble with for myself. Cheers. KF On Thu, 31 Aug 2006 12:21:42 +0100, Stuart Nathan = <stuart.nat***@homecall.co.uk> wrote: Show quoteHide quote > A usercontrol can have a property, which is:- -- => Private MyString as String > Public Property MyProperty() as String > Get > Return myString > End Get > Set(byval Value as String) > myString=3DValue > End Set > End Property > > or you could have > Public Sub ChangeMyString(byval value as string) > mtString=3Dvalue > End Sub > > then to return the string > Public Event ReturnString(byval value as string) > > and in the textxchanged event > RaiseEvent ReturnString(mystring) > > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ |
|||||||||||||||||||||||