By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,826 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,826 IT Pros & Developers. It's quick & easy.

Usercontrol and combobox

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
wrambel wrote:
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
Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

P: n/a
Hi,

Thanks for replaying,

where in my code should I insert your solution?

Greetz,

William

"Chris" <no@spam.com> wrote in message
news:uM**************@TK2MSFTNGP10.phx.gbl...
wrambel wrote:
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

Nov 21 '05 #4

P: n/a
Hi,

Thanks for replaying,

where in my code should I insert your solution?

Greetz,

William
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ej**************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.