|
-
Aug 20th, 2018, 07:18 AM
#1
Thread Starter
Member
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
-
Aug 21st, 2018, 10:59 AM
#2
Hyperactive Member
Re: How to implement events in - _and_ outside of - a usercontrol array?
Last edited by DllHell; Aug 21st, 2018 at 11:03 AM.
-
Aug 21st, 2018, 11:02 AM
#3
Hyperactive Member
Re: How to implement events in - _and_ outside of - a usercontrol array?
 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)
-
Aug 21st, 2018, 11:28 AM
#4
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.
-
Aug 21st, 2018, 04:19 PM
#5
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)
Last edited by LaVolpe; Aug 21st, 2018 at 04:37 PM.
-
Aug 23rd, 2018, 04:07 AM
#6
Thread Starter
Member
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|