是否可以通過編程禁用Application.EnableVisualStyles();
?我想關閉我的應用程序的某個部分的視覺樣式,我可以有一個彩色進度條。我知道你可以使用System.Drawing
來繪製它,但如果我可以暫時關閉它,這會更加簡單。這是可能的還是我將不得不繪製它?c#WinForms - 以編程方式禁用Application.EnableVisualStyles()方法?
0
A
回答
0
積分轉到GreatJobBob鏈接我的MSDN頁面,下面達到了我所期待的。
using System.Windows.Forms.VisualStyles;
Application.VisualStyleState = VisualStyleState.NonClientAreaEnabled;
這讓我改變我的進度條的顏色而不改變我的控件和窗體的其餘部分。
0
創建您自己的進度欄類。禁用Application.EnableVisualStyles
將導致其他用戶界面(如MessageBox)出現問題。這裏有一個基本的課程,讓你開始,只需將forecolor改爲你想要的就可以了。
using System;
using System.Drawing;
using System.Windows.Forms;
class MyProgressBar : Control
{
public MyProgressBar()
{
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, false);
Maximum = 100;
this.ForeColor = Color.Red; //This is where you choose your color
this.BackColor = Color.White;
}
public decimal Minimum { get; set; }
public decimal Maximum { get; set; }
private decimal mValue;
public decimal Value
{
get { return mValue; }
set { mValue = value; Invalidate(); }
}
protected override void OnPaint(PaintEventArgs e)
{
var rc = new RectangleF(0, 0, (float)(this.Width * (Value - Minimum)/Maximum), this.Height);
using (var br = new SolidBrush(this.ForeColor))
{
e.Graphics.FillRectangle(br, rc);
}
base.OnPaint(e);
}
}
相關問題
- 1. 以編程方式調用WinForms contextmenustrip
- 2. 以編程方式禁用Firefox擴展
- 3. 以編程方式禁用UIButton
- 4. 以編程方式啓用/禁用Log4jLogger?
- 5. Winforms TableLayoutPanel以編程方式添加行
- 6. 如何以編程方式禁用SparkUI?
- 7. Android以編程方式禁用onScroll()
- 8. UIWebView以編程方式禁用縮放
- 9. 以編程方式禁用Spring Security
- 10. 以編程方式禁用FirebaseMessagingService
- 11. 以編程方式禁用類別
- 12. 以編程方式禁用UIButton
- 13. 以編程方式禁用ipv4/ipv6
- 14. 如何以編程方式禁用cookie
- 15. 以編程方式禁用AF?
- 16. 以編程方式禁用Alertview
- 17. 以編程方式禁用window.location.reload?
- 18. 以編程方式禁用按鈕
- 19. Spring Boot - 以編程方式禁用AutoConfiguration
- 20. 以編程方式禁用ScollViewer滾動
- 21. 以編程方式禁用麥克風
- 22. 以編程方式禁用Outlook Addin
- 23. 以編程方式禁用gif動畫
- 24. 以編程方式「啓用」TestNG方法
- 25. Com端口以編程方式禁用/啓用C#
- 26. C#WinForms以編程方式添加控件
- 27. C#Winforms:以編程方式顯示Button的懸停狀態
- 28. 到UISlider分配方法以編程方式使用Objective-C的
- 29. 以編程方式禁止Windows警報
- 30. C#以編程方式禁用大型發送卸載(LSO)
我不這麼認爲 – Rahul
我不知道你正在嘗試做的,但是這可能幫助 – GreatJobBob
https://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles .visualstylestate%28V = vs.110%29.aspx – GreatJobBob