Salve,
Come da titolo, ho questo elemento classe che mi personalizza il ToolStripSeparator:
Codice:
public class crossToolStripSeparator : ToolStripSeparator
{
public crossToolStripSeparator()
{
this.Paint += ExtendedToolStripSeparator_Paint;
}
private void ExtendedToolStripSeparator_Paint(object sender, PaintEventArgs e)
{
// Get the separator's width and height.
ToolStripSeparator toolStripSeparator = (ToolStripSeparator)sender;
int width = toolStripSeparator.Width;
int height = toolStripSeparator.Height;
Color foreColor = Color.LightGray;
Color backColor = Color.White;
// Fill the background.
e.Graphics.FillRectangle(new SolidBrush(backColor), 0, 0, width, height);
// Draw the line.
e.Graphics.DrawLine(new Pen(foreColor), 4, height / 2, width - 4, height / 2);
}
}
Che aggiungo al mio menu ( ContextMenuStrip ) tramite
menu.Items.Add(new crossToolStripSeparator());, e fin qui tutto ok, me lo aggiunge correttamente, il problema, è quando lo aggiungo ad un sottomenu del menu con
menu.submenu.DropDownItems.Addnew crossToolStripSeparator()); che non mi va, ovvero, il separatore me lo aggiunge, ma è come se non fosse personalizzato ( mi aggiunge il ToolTipSeparator e non quello che ho creato io, il crossToolTipSeparator ), come mai?
P.S.: Scusate il titolo, mi sono dimenticato di scrivere che il ToolStripSeparator era personalizzato
EDIT:
Scusate, errore mio, l'elemento personalizzato si applica, ero io che applicavo il ToolStripSeparator invece del crossToolTipSeparator