Hi all,
I have a problem with the UI I am working on. I want to dynamically add a label to a table layout panel and add a handle to allow the user to click on that label (right click) and popup a context menu. Now ON that right click, I want to populate some items in the context menu strip. All of this is no problem and I have it working. However based on the even I am linking with AddHandler, I am running into a problem with how the event is managed. Here is my code.
^^ These above are of course just small chunks of the functions I am working with, but I believe they are the relevant parts...
So as you can see, I am using the MouseUp event to track this right click. I am also using some DB code which I cut out of the buildteacher function but you can get the jist.
THE MAIN PROBLEM IS ... when I right click on an "added" -defaultLabel- object on my table layout panel, if I click AGAIN on the context menu strip...say for example to expand a context menu strip item's drop down list ...it completely messes up the event and my third function:
^^^ this guy gets completely confused and doesnt handle anything.
This is getting very confusing, but the short version is, if I click on a context menu strip, after I have already caught the initial right click with the MouseUp event, it kind of looses or forgets what the object was that triggered the first MouseUp event with the initial right click.
MY QUESTION: Is there a better event I can use besided MouseUp to catch right click events? I have used Click and MouseClick, but they didnt seem to work right or at all compared to MouseUp.
If this is completely impossible to understand please let me know and I will try to reword it. It's kind of a strange UI problem. Thanks in advance for any help!!
Josh
I have a problem with the UI I am working on. I want to dynamically add a label to a table layout panel and add a handle to allow the user to click on that label (right click) and popup a context menu. Now ON that right click, I want to populate some items in the context menu strip. All of this is no problem and I have it working. However based on the even I am linking with AddHandler, I am running into a problem with how the event is managed. Here is my code.
VB.NET:
' this code links my new label control to a function called BuildTeacherContextMenuList
Me.tlpDaily.Controls.Add(defaultLabel, colIndex, 0)
AddHandler defaultLabel.MouseUp, AddressOf BuildTeacherContextMenuList
' this is my BuildTeacherContextMenuList function
' if the right mouse button is clicked...
If e.Button = Windows.Forms.MouseButtons.Right Then
tsmiScheduleTeacher.DropDownItems.Clear()
For Each Teacher In dsUsers.Tables(0).Rows
tsmiScheduleTeacher.DropDownItems.Add(Teacher("Teacher"))
Next
End If
^^ These above are of course just small chunks of the functions I am working with, but I believe they are the relevant parts...
So as you can see, I am using the MouseUp event to track this right click. I am also using some DB code which I cut out of the buildteacher function but you can get the jist.
THE MAIN PROBLEM IS ... when I right click on an "added" -defaultLabel- object on my table layout panel, if I click AGAIN on the context menu strip...say for example to expand a context menu strip item's drop down list ...it completely messes up the event and my third function:
VB.NET:
Private Sub AnotherSub Handles tsmiScheduleTeacher.DropDownItemClicked
^^^ this guy gets completely confused and doesnt handle anything.
This is getting very confusing, but the short version is, if I click on a context menu strip, after I have already caught the initial right click with the MouseUp event, it kind of looses or forgets what the object was that triggered the first MouseUp event with the initial right click.
MY QUESTION: Is there a better event I can use besided MouseUp to catch right click events? I have used Click and MouseClick, but they didnt seem to work right or at all compared to MouseUp.
If this is completely impossible to understand please let me know and I will try to reword it. It's kind of a strange UI problem. Thanks in advance for any help!!
Josh