how to change color on progress bar

Jawab how to change color on progress bar

  • 11 Mei 2012 22:44
     
     
    I want to change the progress bar color. Ive tried using the drop down to change its color but seems to not work. Suggestions?

Semua Balasan

  • 11 Mei 2012 23:02
     
     Jawab

    Disable XP Visual Styles is the only easy way. Double click on the project and uncheck the box.

    this may help also - http://support.microsoft.com/?scid=kb;EN-US;323088

    • Ditandai sebagai Jawaban oleh mholmes_3038 12 Mei 2012 15:16
    •  
  • 11 Mei 2012 23:20
     
     
    Works only only question remains. How do I get the smooth appearence XP style had?
  • 12 Mei 2012 0:08
     
     

    look at the link I posted or the thread links on the right "Related Topics" - I don't think there is a simple way to have both.

  • 12 Mei 2012 0:47
     
     
    Did they change this in the 2011 beta so its not a pain or is it still the same in the new beta?
  • 12 Mei 2012 3:36
     
     Jawab Memiliki Kode

    As Devon has stated, the visual styles being enabled is the reason for your problem.  Here is a custom progressbar that disables the visual styles just for itself.  This will allow you to enable XP visual styles, but this control will look and act as though they are not enabled.

    Public Class NoStyleProgressBar
       Inherits ProgressBar
    
       Protected Overrides Sub CreateHandle()
          If Application.RenderWithVisualStyles Then
             Dim currentstate As System.Windows.Forms.VisualStyles.VisualStyleState = Application.VisualStyleState
             'Turn off visual styles
             Application.VisualStyleState = VisualStyles.VisualStyleState.NoneEnabled
    
             'CreateHandle setups the control based on the visual style setting
             MyBase.CreateHandle()
    
             'Reset visual styles  
             Application.VisualStyleState = currentstate
          Else
             MyBase.CreateHandle()
          End If
    
       End Sub
    
    End Class
    Just add this code to your project and rebuild the project.  The new control should be available in your toolbar (unless you set "AutoToolboxPopulate" to false in "Windows Forms Designer" your options).

    • Ditandai sebagai Jawaban oleh mholmes_3038 12 Mei 2012 15:16
    •  
  • 12 Mei 2012 5:54
     
     Jawab

    To create a different colored progress bar (green, yellow, red) with XP visual styles disabled, I found this nice video a while ago. Works great for me!

    http://www.youtube.com/watch?v=X1HdElLZJeE

    Otherwise, if you want a progress bar with XP styles, I found another thread:

    http://social.msdn.microsoft.com/Forums/bg-BG/vbgeneral/thread/0907165b-5739-41dd-9b57-43dc3434f03a

    Hope it helps!

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

  • 12 Mei 2012 15:16
     
     
    Thanks guys not sure who answer to mark correct here lol