Reputation: 53
I am attempting to create a toolstrip class that inherits from the system.windows.forms.toolstrip class but specifies the styling to make consistent across our applications. The individual buttons that get added to the toolstrip have a displaystyle property that specify if you want to display an imageonly, textonly, or both. Is there a way I can specify the displaystyle for all buttons to be used in my toolstrip? I'd like to set it in my toolstrip class and have it applied across all applications rather than having to set this in every application.
Upvotes: 0
Views: 413
Reputation: 3018
Create a WindowsFormsControlLibrary project in your solution (for example "ConsistentControls"). Define a class (for example "ConsistentToolStripButton"). Define its capabilities like this.
using System;
using System.Windows.Forms;
namespace ConsistentControls
{
public class ConsistentToolStripButton : ToolStripButton
{
public override System.Windows.Forms.ToolStripItemDisplayStyle DisplayStyle
{
get
{
return base.DisplayStyle;
}
set
{
}
}
public ConsistentToolStripButton()
{
base.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
}
}
}
Now you can use this class in, for example "WindowsFormsApplication1", "WindowsFormsApplication2", "WindowsFormsApplication3" and so on...
Here is a screenshot of Design-Time development
Upvotes: 1