Results 1 to 2 of 2

Thread: UserControl Event Problem

  1. #1
    Adept Developer
    Guest

    Question UserControl Event Problem

    I have some code here for a UserControl that uses a ComboBox in it. My code works, but I want to be able to use the normal events of the ComboBox from the code that calls my UserControl. The name of the UserContrl is 'SelectBox', so I would really like to say:

    Code:
    Private Sub SelectBox1_Click()
      'Code Block
    End Sub
    If anyone could help, I'd appreciate it.

    -Steve

    Code:
    Public Sub AddItemValue(ByVal strText As String, strValue As String)
      Combo1.AddItem strText
      Dim m_strKeys() As String
      ReDim Preserve m_strKeys(Combo1.ListCount)
      m_strKeys(Combo1.ListCount - 1) = strValue
    End Sub
    
    Public Function GetValue(iIndex As Integer) As String
      GetValue = m_strKeys(iIndex)
    End Function

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    In the (General) section of your usercontrol code:-

    Event Click()

    Private Sub Combo_Click()

    RaiseEvent Click

    End Sub

    Now,

    Private Sub SelectBox1_Click()
    'Code Block
    End Sub

    will be called when the combobox is clicked.

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