[英]How can I change the properties of controls in all tabs in Windows Forms Application?
[英]How can I change `All Desired` properties of the windows controls?
我正在使用WinForms:C#.NET。
我遇到了ContextMenuStrip
和Toolstrip
的問題。 Visual Stuido的屬性編輯器不允許我更改所需的屬性。
下面是我多么希望我的快照ContextMenuStrip
到looklike與同樣是與本案Toolstrip
。 我不知道該怎么做。
如果我需要學習一些東西,請建議適當的好材料(教程,文章等)
您必須將Renderer屬性分配給一個類,該類以所需的方式呈現CMS或工具欄。 使用以下代碼作為模板開始:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
contextMenuStrip1.Renderer = new myRenderer();
}
class myRenderer : ToolStripProfessionalRenderer {
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) {
// Replace this with your own drawing code...
base.OnRenderToolStripBackground(e);
}
}
}
沒有可以設置為使ContextMenuStrip
看起來像這樣的單個屬性。
您需要創建自己的ToolStripRenderer
類,以繪制類似的菜單,然后將ContextMenuStrip的Renderer
屬性設置為ToolStripRenderer
的實例。
祝好運。
編輯 :您可以在此處找到示例代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.