Usercontrol and combobox

  • Thread starter Thread starter wrambel
  • Start date Start date
W

wrambel

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_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ComboBox.SelectedIndexChanged

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
 
wrambel said:
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_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ComboBox.SelectedIndexChanged

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

Not too fimiliar with user controls but calling

MyBase.OnSelectionChangeCommitted(EventArgs.Empty)

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

Chris
 
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,nothing)
Myevent(TheControl,nothing)
and a lot more

I hope this helps,

Cor
 
Hi,

Thanks for replaying,

where in my code should I insert your solution?

Greetz,

William
 
Hi,

Thanks for replaying,

where in my code should I insert your solution?

Greetz,

William
 
Back
Top