Usercontrol and combobox

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

    #1

    Usercontrol and combobox

    Hi,

    Can someone tell me how I start an event automatically when I change an item
    in a combobox, which is in a usercontroller.

    I tried the following but it doesn't work;

    ComboBox UserController;

    Public Class ucComboBox
    Public Event Start()

    #Region " Windows Form Designer generated code " ..........

    Protected Overridable Sub ComboBox_Select edIndexChanged( ByVal sender As
    System.Object, ByVal e As System.EventArg s) Handles
    ComboBox.Select edIndexChanged

    RaiseEvent Start()

    End Sub

    End Class

    Main form;
    Public Class form1

    Friend WithEvents MySender As ucComboBox

    #Region " Windows Form Designer generated code " ..........

    Private Sub MySender_Start( ) Handles MySender.Start

    MsgBox("Do something!")

    End Sub

    End Class






  • Chris

    #2
    Re: Usercontrol and combobox

    wrambel wrote:[color=blue]
    > Hi,
    >
    > Can someone tell me how I start an event automatically when I change an item
    > in a combobox, which is in a usercontroller.
    >
    > I tried the following but it doesn't work;
    >
    > ComboBox UserController;
    >
    > Public Class ucComboBox
    > Public Event Start()
    >
    > #Region " Windows Form Designer generated code " ..........
    >
    > Protected Overridable Sub ComboBox_Select edIndexChanged( ByVal sender As
    > System.Object, ByVal e As System.EventArg s) Handles
    > ComboBox.Select edIndexChanged
    >
    > RaiseEvent Start()
    >
    > End Sub
    >
    > End Class
    >
    > Main form;
    > Public Class form1
    >
    > Friend WithEvents MySender As ucComboBox
    >
    > #Region " Windows Form Designer generated code " ..........
    >
    > Private Sub MySender_Start( ) Handles MySender.Start
    >
    > MsgBox("Do something!")
    >
    > End Sub
    >
    > End Class
    >
    >
    >
    >
    >
    >[/color]

    Not too fimiliar with user controls but calling

    MyBase.OnSelect ionChangeCommit ted(EventArgs.E mpty)

    in my inherited combobox forces the event to fire for anyone handling
    the event.

    Chris

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Usercontrol and combobox

      wrambel,

      Why do you want to raise an event when you just can call the sub that
      handles that event?

      Myevent(nothing ,nothing)
      Myevent(me,noth ing)
      Myevent(TheCont rol,nothing)
      and a lot more

      I hope this helps,

      Cor


      Comment

      • wrambel

        #4
        Re: Usercontrol and combobox

        Hi,

        Thanks for replaying,

        where in my code should I insert your solution?

        Greetz,

        William

        "Chris" <no@spam.com> wrote in message
        news:uMzVStklFH A.3552@TK2MSFTN GP10.phx.gbl...[color=blue]
        > wrambel wrote:[color=green]
        >> Hi,
        >>
        >> Can someone tell me how I start an event automatically when I change an
        >> item in a combobox, which is in a usercontroller.
        >>
        >> I tried the following but it doesn't work;
        >>
        >> ComboBox UserController;
        >>
        >> Public Class ucComboBox
        >> Public Event Start()
        >>
        >> #Region " Windows Form Designer generated code " ..........
        >>
        >> Protected Overridable Sub ComboBox_Select edIndexChanged( ByVal sender As
        >> System.Object, ByVal e As System.EventArg s) Handles
        >> ComboBox.Select edIndexChanged
        >>
        >> RaiseEvent Start()
        >>
        >> End Sub
        >>
        >> End Class
        >>
        >> Main form;
        >> Public Class form1
        >>
        >> Friend WithEvents MySender As ucComboBox
        >>
        >> #Region " Windows Form Designer generated code " ..........
        >>
        >> Private Sub MySender_Start( ) Handles MySender.Start
        >>
        >> MsgBox("Do something!")
        >>
        >> End Sub
        >>
        >> End Class
        >>
        >>
        >>
        >>
        >>
        >>[/color]
        >
        > Not too fimiliar with user controls but calling
        >
        > MyBase.OnSelect ionChangeCommit ted(EventArgs.E mpty)
        >
        > in my inherited combobox forces the event to fire for anyone handling the
        > event.
        >
        > Chris[/color]


        Comment

        • wrambel

          #5
          Re: Usercontrol and combobox

          Hi,

          Thanks for replaying,

          where in my code should I insert your solution?

          Greetz,

          William
          "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
          news:ejd6gCllFH A.2484@TK2MSFTN GP15.phx.gbl...[color=blue]
          > wrambel,
          >
          > Why do you want to raise an event when you just can call the sub that
          > handles that event?
          >
          > Myevent(nothing ,nothing)
          > Myevent(me,noth ing)
          > Myevent(TheCont rol,nothing)
          > and a lot more
          >
          > I hope this helps,
          >
          > Cor
          >[/color]


          Comment

          Working...