ToolStripProgressBar绘画中的问题(VS.Net 2010,WinForms). [英] Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).

查看:152
本文介绍了ToolStripProgressBar绘画中的问题(VS.Net 2010,WinForms).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确保在系统中启用ApplyVisualStyles.将ToolStripProgressBar放置在工具条上,运行您的应用程序并最小化表单.现在,将计算机的主题更改为Windows Classic并还原该表单.看到ToolStripProgrssBar的内部变黑了.如果刷新表格,它甚至都不会改变.如果进度始终保持黑色,用户如何知道进度状态?有什么办法解决这个问题吗?问候.

Ensure ApplyVisualStyles is enabled in your system. Place a ToolStripProgressBar on a toolstrip, run your application and minimize the form. Now change the theme of your computer to Windows Classic and restore the form. See the interior of the ToolStripProgrssBar becomes black. It doesn''t even change if you refresh the form. How does the user know the status of the progress if it remains black always? Any approach to fugure it out? Regards.

推荐答案

您是否希望用户经常启动流程,最小化表单,更改主题然后恢复表单?
are you expecting users to often start a process, minimise a form, change the theme and then restore the form ?


似乎是一个错误.解决方法是处理e.Category = VisualStyle的SystemEvents.UserPreferenceChanged并将进度条样式更改为某种样式,然后再次返回.

Seems to be a bug. A workaround is to handle SystemEvents.UserPreferenceChanged for e.Category=VisualStyle and change the progressbar style to something and back again.

Imports System
Imports Microsoft.Win32

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler SystemEvents.UserPreferenceChanged, AddressOf SystemEvents_UserPreferenceChanged
    End Sub

    Private Sub SystemEvents_UserPreferenceChanged(ByVal sender As Object, ByVal e As UserPreferenceChangedEventArgs)
        If e.Category = UserPreferenceCategory.VisualStyle Then
            Dim CurrentStyle As ProgressBarStyle = ToolStripProgressBar1.Style

            For Each Style As ProgressBarStyle In [Enum].GetValues(GetType(ProgressBarStyle))
                If Not Style.Equals(CurrentStyle) Then
                    ToolStripProgressBar1.Style = Style
                    Exit For
                End If
            Next

            ToolStripProgressBar1.Style = CurrentStyle
        End If
    End Sub
End Class


这篇关于ToolStripProgressBar绘画中的问题(VS.Net 2010,WinForms).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆