Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am making a ToolBar menu UserControl for my project. The ToolBar will have n quantities of buttons based on each situation it undergoes. So for example in certain windows toolbar will have new, edit, delete buttons, but in other it might have upload, download, and print. This is a simple example, it gets more complicated than that.

Here is what i have so far:
In the UserControl (ToolBar)
VB
'NEW Button
Public Event btnNew_Click As btnNew_ClickedEventHandler
Public Delegate Sub btnNew_ClickedEventHandler(sender As Object)
Private Sub btnNew_MouseUp(sender As Object, e As MouseButtonEventArgs)
    RaiseEvent btnNew_Click(Me)
End Sub


This code will make this event visible from the Window in xaml
<toolbar btnNew_Click="Code_for_New_Record"/>


So far so good (everything works). But I want to check if my Event is Attached from the MainWindow and if it is not, to hide it.

So for example, if i had buttons for update, delete, print, etc. And the programer for the MainWindow only coded the New Button, only the new Button should show.

Question:
How can I tell if the Event is attached or called? I would like to have some code that says

IF myEvent IsNot attached then
button.visibility = collapsed
end if

Thanks for all your help in advance!
Posted

1 solution

hope this link[^] will help you
 
Share this answer
 
Comments
cogentp 8-Jan-15 3:00am    
I don't see how that helps me. What i want to do is, check if the user has added an Event in the Toolbar usercontrol, and if he/she has, then show the icon.

I tried the code in the link, but it seems to only work if the event is in the very same class as the one your are calling from. I need to check if another class is referencing my event, and if yes, then show, if no, the hide.
Thava Rajan 8-Jan-15 3:32am    
well as per your need you can use the condition inside the class, may i know why you want to check the event outside the class?
can you please explain the situation why and where you use this kind of implementation
cogentp 9-Jan-15 23:35pm    
You were right, sorry about that. VB.NET has a particularity that gets confusing, and this is such a case. In the example they were referencing something that hadn´t been previously referenced in code...but the vb compiler did it behind the scenes and intelisence didn´t pick it up. Once I copy pasted the code as is, it worked. thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900