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

How to raise a standard event on windows component

P: n/a
I have a combobox with a SelectionChangeCommitted event handler, and am
having a problem raising this event.

For example,

raiseEvent mycombobox.SelectionChangeCommitted

gives me an error about not being ended properly. But it won't accept
parameters either. What's the trick here?

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


P: n/a
As per the msdn document:
http://msdn.microsoft.com/library/de...raiseevent.asp

"You cannot use RaiseEvent to raise events that are not explicitly declared
in the module."

Since the SelectionChangeCommitted is defined in the combobox, you cannot
raise the event using RaiseEvent. Ofcourse, you can still raise the event
using mycombobox_SelectionChangeCommitted and pass in the parameters.

hope this helps..
Imran.
"Jeremy" <je****@ninprodata.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a combobox with a SelectionChangeCommitted event handler, and am
having a problem raising this event.

For example,

raiseEvent mycombobox.SelectionChangeCommitted

gives me an error about not being ended properly. But it won't accept
parameters either. What's the trick here?

Jeremy

Nov 21 '05 #2

P: n/a
* "Jeremy" <je****@ninprodata.com> scripsit:
I have a combobox with a SelectionChangeCommitted event handler, and am
having a problem raising this event.

For example,

raiseEvent mycombobox.SelectionChangeCommitted

gives me an error about not being ended properly. But it won't accept
parameters either. What's the trick here?


Where do you use this code? Notice that 'RaiseEvent' will only work
inside the class that defines the event. To raise the event from
outside the class, provide a public method that expects the event
arguments in a parameter and raises the event using 'RaiseEvent'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3

P: n/a
Jeremy,

Why not just call the method?

Cor
Nov 21 '05 #4

P: n/a
Jeremy,
As the other's suggest only the class itself can raise its events. To allow
derived classes to raise base class events there is a standard Event pattern
you should consider implementing in your classes.

http://msdn.microsoft.com/library/de...Guidelines.asp

Knowing this pattern will allow you to create a custom ComboBox class that
will allow you to raise the event you want.

Something like:

Public Class ComboBoxEx
Inherits ComboBox

Public Sub RaiseSelectionChangeCommitted()
MyBase.OnSelectionChangeCommitted(EventArgs.Empty)
End Sub

End Class

Then instead of using ComboBox, you can use ComboBoxEx on your forms, then
every place you want to raise the SelectionChangeCommitted event, you simply
call the RaiseSelectionChangeCommitted method.

Hope this helps
Jay

"Jeremy" <je****@ninprodata.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a combobox with a SelectionChangeCommitted event handler, and am
having a problem raising this event.

For example,

raiseEvent mycombobox.SelectionChangeCommitted

gives me an error about not being ended properly. But it won't accept
parameters either. What's the trick here?

Jeremy

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.