Windows Develop Bookmark and Share   
 index > Windows Forms General > ToolStripDropDownMenu - doesn't work - base.DropDown = new MenuDropDown();
 

ToolStripDropDownMenu - doesn't work - base.DropDown = new MenuDropDown();

i'm trying to override the Onpaint event of the dropdownmenu.
this is what i did.
but of you recbuild and execute, it doesn't make use of the custom made 'ToolStripDropDownMenu'
what am i doing wrong?

[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)]
public class cMyToolStripMenuItem : ToolStripMenuItem
{
public cMyToolStripMenuItem()
{
if (this.Owner != null)
{
base.DropDown = new MenuDropDown();
}

}
}

public class MenuDropDown : ToolStripDropDownMenu
{

public MenuDropDown()
{

base.BackColor = Color.Transparent;
//base.AutoSize = false;
MessageBox.Show
(
"MenuDropDown",
"MenuDropDown",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
protected override void OnPaint(PaintEventArgs e)
{

base.OnPaint(e);
}

}
Natural_D  Saturday, September 26, 2009 2:04 PM
What's with the this.Owner test? That's why it doesn't work, it has an owner.

Hans Passant.
  • Marked As Answer byNatural_D Saturday, September 26, 2009 7:22 PM
  •  
nobugz  Saturday, September 26, 2009 4:01 PM
What's with the this.Owner test? That's why it doesn't work, it has an owner.

Hans Passant.
  • Marked As Answer byNatural_D Saturday, September 26, 2009 7:22 PM
  •  
nobugz  Saturday, September 26, 2009 4:01 PM
yeah, but before i move it there, it didn't work also.

right now, before your poste, i tried again.
and voila, it works.

but it override the draw event of the other post on the submenu's.

: )
Natural_D  Saturday, September 26, 2009 4:06 PM

You can use google to search for other answers

Custom Search

More Threads

• Force ComboBox userChange event
• IndexOutOfRangeException occurred when datagridview clicked.
• ToolWindows Acting Strange
• Repeating Objects List on a winform
• "Enter"
• Can Crystal Report display multiple dataSets?
• calling a procedure C#/windows forms
• Dynamically loading MDIchild forms at runtime
• Button Event Not firing ( should be simple )
• Show a group of forms in one form