Windows Develop Bookmark and Share   
 index > Windows Forms General > Prevent toolstripborder form being rendered
 

Prevent toolstripborder form being rendered

Hi,

I've got a toolstrip and I don't want to render its border. How can I do this? (Maybe render an 'empty' border)

Ralf

Ralf Euser  Tuesday, March 04, 2008 10:04 AM
Hello Ralf Euser,

You can play with ToolStripRenderer's ColorTable in order to accomplish your goal.Setting it's ToolStripBorder border color property to needed color..
It could look like:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
toolStrip1.Renderer = new ToolStripProfessionalRenderer(new BorderlessProfessionalColorTable());
}
}

public class BorderlessProfessionalColorTable
: ProfessionalColorTable
{
public override Color ToolStripBorder
{
get { return Color.Transparent; }
}
}

Regards,
Oleh.
Oleh Svintsitskyy  Thursday, March 06, 2008 8:35 PM
Hello Ralf Euser,

You can play with ToolStripRenderer's ColorTable in order to accomplish your goal.Setting it's ToolStripBorder border color property to needed color..
It could look like:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
toolStrip1.Renderer = new ToolStripProfessionalRenderer(new BorderlessProfessionalColorTable());
}
}

public class BorderlessProfessionalColorTable
: ProfessionalColorTable
{
public override Color ToolStripBorder
{
get { return Color.Transparent; }
}
}

Regards,
Oleh.
Oleh Svintsitskyy  Thursday, March 06, 2008 8:35 PM

Thnx. And if I also want to prevent the RoundedEdges option to be on?

Ralf Euser  Sunday, March 09, 2008 11:25 PM
Hello Ralf Euser,

There is a RoundedEdges property which controls edge styles.
You could update it after constructing custom renderer, like

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ToolStripProfessionalRenderer renderer = new ToolStripProfessionalRenderer(new BorderlessProfessionalColorTable());
renderer.RoundEdges = false;
toolStrip1.Renderer = renderer;
}
}

public class BorderlessProfessionalColorTable
: ProfessionalColorTable
{
public override Color ToolStripBorder
{
get { return Color.Transparent; }
}
}


or update it in constructor, like

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
toolStrip1.Renderer = new ToolStripProfessionalRenderer(new BorderlessProfessionalColorTable());
}
}

public class BorderlessProfessionalColorTable
: ProfessionalColorTable
{
public BorderlessProfessionalColorTable()
: base()
{
this.RoundEdges = false;
}
public override Color ToolStripBorder
{
get { return Color.Transparent; }
}
}


Hope this helps.
Regards,
Oleh.
Oleh Svintsitskyy  Tuesday, March 11, 2008 12:55 PM

You can use google to search for other answers

Custom Search

More Threads

• Error Creating Window Handle
• Login Property
• [SOLVED]Forms and Menory usage
• Bit fields
• Vertical Scrolling triggers Horizontal scrolling
• Databinding more complex types
• Working with C# and VB.net in same Project
• Printing diractly to a Label Printer
• Any one use joyGetDevCaps API on VB.Net
• [Q] ASP.net and IIS 5.1