How to implement events in - _and_ outside of - a usercontrol array?
Hi everyone,
In a VB6 application I have to replace every ancient Sheridan SSRibbon control by a usercontrol "NewSSRibbon". The main form contains both SSRibbons in a control array and "stand alone" SSRibbons with an empty Index property.
I have to implement the Click event in NewSSRibbon so that both handler signatures Sub btnNewSSRibbon1_Click() and Sub btnNewSSRibbon2_Click(Index As Integer) work.
Declaring something like Public Event Click() next to Public Event Click(Index As Integer) obviously causes a compile error. "Optional Index As Integer" is not allowed.
In addition, if this problem can be solved: how do I provide the correct Index? In Public Event Click(Index As Integer), Index is merely a placeholder. It doesn't refer to anything, which doesn't look right to me.
And what would the RaiseEvent Click - statements look llike?
How do I go about it?
Thanks in advance!
Cooz
Re: How to implement events in - _and_ outside of - a usercontrol array?
Re: How to implement events in - _and_ outside of - a usercontrol array?
Quote:
Originally Posted by
Cooz
"Optional Index As Integer" is not allowed.
remove the optional and it will work
Code:
Event Click(index As Integer)
to raise it, call it in your user control:
Code:
RaiseEvent Click(idx)
Re: How to implement events in - _and_ outside of - a usercontrol array?
The Index gets implemented by the plumbing that underlies the control array mechanism. You don't need to do anything with it within the UserControl.
Re: How to implement events in - _and_ outside of - a usercontrol array?
To piggyback on dilettante's reply.
Don't include the Index parameter. When you have 1 instance of your control, the form hosting it will show this event:
btnNewSSRibbon2_Click()
If you change the control's Index property on the its hosting form, to a numeric value, then when you look at the event in the form:
btnNewSSRibbon2_Click(Index As Integer)
Re: How to implement events in - _and_ outside of - a usercontrol array?
Hi all,
Indeed - I was making a bit of a fuss here; it is far simpler than I expected. Got it working now. Thanks!
Kind regards,
Cooz