Usercontrol and combobox

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
 
C

Chris

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
 
C

Cor Ligthert [MVP]

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
 
W

wrambel

Hi,

Thanks for replaying,

where in my code should I insert your solution?

Greetz,

William
 
W

wrambel

Hi,

Thanks for replaying,

where in my code should I insert your solution?

Greetz,

William
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top