|
-
Jan 16th, 2004, 07:25 AM
#1
Handling two events
I'm trying to get my Sub, named "Whatever" to handle the events raised by two separate controls: a button, and a toolbar. The toolbar is a custom one, and as a result, the signatures of the two are not the same.
Is there anything I can do so that "Whatever" can somehow handle both their events
-
Jan 16th, 2004, 07:39 AM
#2
Yup, just stick a comma at the end:
Handles Button1.Click, Button2.Click
All signatures are the same using:
ByVal sender As System.Object, ByVal e As System.EventArgs
They just impliment different version of them, and you can check which control is was, by looking at the "sender" value.
-
Jan 17th, 2004, 03:02 AM
#3
Unfortunately, the signature here isn't the same as it is for the button click. 
Let me show you:
VB Code:
Public Sub Whatever(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles UltraToolbarsManager1.ToolClick
If TypeOf e.Tool Is Infragistics.Win.UltraWinToolbars.PopupColorPickerTool Then
Me.ForeColor = color1.SelectedColor
End If
End Sub
Here is the Sub I've created to handle the toolbar clicks. Now I need Button1 to actually call this with the proper 'arguments'
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'I have no idea what to put here
End Sub
Now you see what's wrong? I'm still new to VB.NET, so please explain to me if I'm going about things the wrong way.
-
Jan 17th, 2004, 03:09 AM
#4
Sleep mode
A blind shot .
VB Code:
'In Button1_Click
Whatever(sender, DirectCast(e, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs))
-
Jan 17th, 2004, 05:55 AM
#5
PowerPoster
Hi,
Is it too easy to suggest the code for button1 as:
ToolBarButton.PerformClick
??
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jan 17th, 2004, 06:42 AM
#6
VB Code:
ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs
The class ToolClickEventArgs is an implementation class of EventArgs so any sub declared as:-
VB Code:
Private Sub CombinedEventHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Will work.
-
Jan 17th, 2004, 07:08 AM
#7
Originally posted by Merrion
The class ToolClickEventArgs is an implementation class of EventArgs so any sub declared as:-
There is only 1 base event signature, and everything (as stated) is based on those, and you can just cast it to the one you need. But saying that, if you are trying to use the same event to handle two different controls, and you actually need specific info from the argument (well one of them), then are you sure you dont need two different events that call another procedure with the corrected arguments ?
-
Jan 17th, 2004, 11:51 AM
#8
Originally posted by mendhak
Unfortunately, the signature here isn't the same as it is for the button click. 
Let me show you:
VB Code:
Public Sub Whatever(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles UltraToolbarsManager1.ToolClick
If TypeOf e.Tool Is Infragistics.Win.UltraWinToolbars.PopupColorPickerTool Then
Me.ForeColor = color1.SelectedColor
End If
End Sub
Here is the Sub I've created to handle the toolbar clicks. Now I need Button1 to actually call this with the proper 'arguments'
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'I have no idea what to put here
End Sub
Now you see what's wrong? I'm still new to VB.NET, so please explain to me if I'm going about things the wrong way.
you dumb frog! hehe jk
first, rename UltraWinToolbars to UWinToolbars (sounds better). so you'd have Infragistics.Win.UWinToolbars (+ you can rename Infragistics to Infrogistics)
second, do what merrion said
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
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
|