I am doing a desktop application in c #, it has a MenuStrip
and I would like to make an Activity Log, that is, write down in a table the user's information and what activities he did.
I have the method that is executed when you click on an item of MenuStrip
.
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
logact.graboLogActividad(e.ClickedItem.Text);
}
But I'm only interested in Items that are the last of a string.
What I mean:
If the item has a defined click, that is, a method is executed, it interests me.
But if the item displays a set of items, it does not interest me and I would like to skip it.
For now: logact.graboLogActividad(e.ClickedItem.Text);
saves all the clicks that the user is doing in the table.
Clearly I have to ask using sender
and / or e
in what situation I am in.
I would also like to get the string of items that ends with the execution of a method.
For example:
If the method is in the main tree, it would be obtained by clicking on "Remate" the text "Remate" because the associated method would be executed immediately.
but if the method is after several levels, such as Files / Customers / Maintenance / High I would like to obtain: this chain and not only "Altas" in order to differentiate it from: Archives / Articles / Maintenance / Alta
I would not like to record several entries in the Activity Log: "Files", "Articles", "Maintenance" and "High", because in reality what was done was a "High" everything else was the way to get through the Menu.
I have noticed that I have 2 MenuStrip components: ToolStripDropDownItem
and ToolStripItem
QUESTIONS:
A) How do I identify a transit item of an execution item.
B) How do I get the string of items that leads to an execution item (their parents).