Results 1 to 3 of 3

Thread: help me with usercontrol

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    help me with usercontrol

    i have created an user control and have added it into my form.

    i have coded the usercontrol as when got focus its value increases by 1 and an msgbox showing its value is displayed. when i had run the form and set the focus to the usercontrol it messaged the increasing value of the control 39 times

    Code:
       
    Private Sub MyComboTxt_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
            MyCombo.Visible = True
            MyCombo.Focus()
            MyLabel.Visible = False
            MyCombo.Text = MyLabel.Text
            If Len(Trim(MyCombo.Text)) <> 0 And MyCombo.Items.Count <> 0 Then
                MyCombo.DroppedDown = True
                MyCombo.SelectAll()
            End If
            MyCombo.Text = MyCombo.Text + 1
            MsgBox(MyCombo.Text)
    end sub

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Re: help me with usercontrol

    actually i wanted an user control which has 2 object, one label and one combo box.

    when the control has the focus(label is not visible) it must allow the user to select an item from the combo list and when it loses its focus(combo is not visible) it must set the value of the label to its text

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: help me with usercontrol

    What you're asking for is not possible. If you have a UserControl with only a Label on it then there's nothing to receive focus. You could handle the Click event of the Label and display the ComboBox again but you won't be able to tab to it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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