CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: UserControl

  1. #1
    Join Date
    Jun 2001
    Posts
    28

    UserControl

    Hi!

    I need help for user control.

    On "user control" I have ListBox.
    I want to access that list box in form which is included in same usercontol. I wrote some code but it is giving error. error'424'bject requried.

    Usercontrol(test.ctl) code

    Private Sub UserControl_Initialize()
    Load Form1
    List1.AddItem "A", "0"
    List1.AddItem "K", "1"
    List1.AddItem "G", "2"
    List1.AddItem "R", "3"
    End Sub

    Private Sub cmdbutton_Click()
    Form1.Show vbmodel,me
    End Sub

    Form1
    Private Sub Form_Load()
    txttest.value=test.list1.text
    (Nameof usercontrol.controlname.property)
    End Sub

    I am not able to refernce the component from usercontrol.

    Thanks,
    Anita



  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: UserControl

    if the list box is in the form, should you write

    form1.list1.additem

    instead ?

    cksiow
    http://vblib.virtualave.net - share our codes


  3. #3
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: UserControl

    I think you need writing function in UserControl.
    In user control write:
    Public Function RetProp() As String
    RetProp = List1.Text
    End Function

    In form use:
    txttest.value = test.RetProp()

    P.S. In listbox properties Text return zero lenght value string

    Andy Tower

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured