User Controls basic question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kristian Frost

    #1

    User Controls basic question

    Hi,
    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

    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
  • Stuart Nathan

    #2
    Re: User Controls basic question

    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(by val value as string)

    and in the textxchanged event
    RaiseEvent ReturnString(my string)


    Comment

    • Kristian Frost

      #3
      Re: User Controls basic question

      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 User
      Controls I had been having trouble with for myself.

      Cheers.
      KF

      On Thu, 31 Aug 2006 12:21:42 +0100, Stuart Nathan
      <stuart.nathan@ homecall.co.ukw rote:
      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(by val value as string)
      >
      and in the textxchanged event
      RaiseEvent ReturnString(my string)
      >
      >


      --
      Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

      Comment

      Working...