Cannot get the parent of the menu Item

Hi ,

I have a toolstripMenuItem with many children underneath.

When I am clicking on the mnuchild i would like to get the name of the parent menu.

I have tried everything But i cannot find anything that brings the result.

I was expecting

mnuchild.Parent but there is not such a property/method.
any ideas?

thanks a lot
vbjunkie

[354 byte] By [vbjunkie] at [2007-12-16]
# 1
In the child menu item's click event, you can cast the sender event arg to a ToolStripItem and check its OwnerItem property.

private void newToolStripMenuItem_Click(object sender, EventArgs e)

{

ToolStripItem tsi = sender as ToolStripItem;

MessageBox.Show(tsi.OwnerItem.Name.ToString());

}

BenWillett at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Sorry for late reply.Thanks for the code.

Unforturnately my alert does not work properly
I will try now

thanks

vbjunkie at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3

Thanks for the code However on my vb.net beta 2 2005

I dont have "Owner.Item"



Private Sub TestparentToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestparentToolStripMenuItem.Click

Dim tsi As ToolStripItem = CType(sender, ToolStripItem)

MessageBox.Show(tsi.Owner.Items.ToString())

end Sub



Any ideas

vbjunkie at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...