I am trying to build a cool menu inside my program. I am building a schedule program where the user is to choose customer, my thought is to let the user enter a form with 5 text boxes. If it is a new customer he just types the info in ther, but it it is a returning customer I wan´t to have a contextmenu accesible throu right clicking inside the form. I have got so far that I load all the menu items from a database but here comes the problem. How can I determine witch item was clicked. Since you have to specify each Click event for every menuitem. I cant figure out how to do this in code. VB won´t let me add subs in a loop from a dataset. Is there a way to get the text property in the click event if you get what i mean.. Then i can check against the database ang fetch the right data.
If you cast the sender object to a menuitem object, you will have access to its properties. I think the menuitem has a text property you can access that would tell you which one it was. Also, if you named them as you add them to the menu, you could look at the name property.
Sorry if I am a bit slow but I dont get the "cast the sender object to a menuitem object" part. Can you show me in code how that is done? This is my OnClick event.
Protected Sub menuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)