none
Can I change the color of a ProgressBar In Visual Basic 2010

    Question

  • Is there a way that I can change the Color/Colour of a ProgressBar, or is it a Color/Colour that I have to put up with?

    At the Moment the Color/Colour is green...

    Kind Regards Gary


    Gary Simpson
    Thursday, February 03, 2011 8:03 PM

Answers

  • Hi Gary,

    You can put the code:

    ProgressBar1.ForeColor = Color.Aqua

    whenever you want to change progress bar color.

    Preferably, set the ForeColor property in designer before the form shows up, through properties window. However as i stated previously, you need to turn off (uncheck) "Enable XP Visual Styles" through solution explorer -> right click your project ->  "properties" -> Application tab. like in the screenshot .

     

     


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    • Marked as answer by Gary Simpson Friday, February 04, 2011 1:31 AM
    Thursday, February 03, 2011 10:21 PM

All replies

  • From what I know of VB, I don't think its possible to change the color, but I think you can put a image of a color for the loader.

    *correct me if i'm wrong*

     


    Coding is my way of having fun
    Thursday, February 03, 2011 8:07 PM
  • Yes you can. But first you need to disable the setting "Enable Visual Styles" under project properties or make this line false in Application.myapp in solution explorer:

    <EnableVisualStyles> false</EnableVisualStyles>

    Then you can change ForeColor property to apply different color to progressbar like this:

    ProgressBar1.ForeColor = Color.Red

    HTH.


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    Thursday, February 03, 2011 8:26 PM
  • Hi  Saygılarımla, Onur Güzel

    Below is the code i have and where would i put your code:

    ProgressBar1.Forecolor=Color.red

    And I have been to my setting but I cannot find Visual Styles under project properties

    Kind Regards

    Gary

    Public Class Form1
    
      Dim CPU As Integer
      Dim Ram As Integer
    
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
        Timer2.Enabled = True
      End Sub
    
      Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
        CPU = PerformanceCounter1.NextValue
        Ram = PerformanceCounter2.NextValue
      End Sub
    
      Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        ProgressBar1.ForeColor = Color.Aqua
        If ProgressBar1.Value < CPU Then
          ProgressBar1.Value += 1
        ElseIf ProgressBar1.Value > CPU Then
          ProgressBar1.Value -= 1
        End If
    
        If ProgressBar2.Value < Ram Then
          ProgressBar2.Value += 1
        ElseIf ProgressBar2.Value > Ram Then
        End If
    
    
        Label3.Text = ProgressBar1.Value.ToString + "%"
        Label4.Text = ProgressBar2.Value.ToString + "%"
    
      End Sub
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
      End Sub
    End Class
    • Edited by Gary Simpson Thursday, February 03, 2011 10:16 PM the code did not copy properly
    Thursday, February 03, 2011 10:04 PM
  • Hi Gary,

    You can put the code:

    ProgressBar1.ForeColor = Color.Aqua

    whenever you want to change progress bar color.

    Preferably, set the ForeColor property in designer before the form shows up, through properties window. However as i stated previously, you need to turn off (uncheck) "Enable XP Visual Styles" through solution explorer -> right click your project ->  "properties" -> Application tab. like in the screenshot .

     

     


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    • Marked as answer by Gary Simpson Friday, February 04, 2011 1:31 AM
    Thursday, February 03, 2011 10:21 PM
  • Hi  Saygılarımla, Onur Güzel,

    Thank you very Much For your Replies, you have been a great help to me, in showing me the way to do things.

    Kind Reards

    Gary 


    Gary Simpson
    Friday, February 04, 2011 1:35 AM
  • Hi MetaShadow7,

    you can change the color. you asked me to correct you if you was wrong...LOL

    Saygılarımla, Onur Güzel helped me out. check it out mate. but thank you for getting back to me it is nice to know people out there are willing to help.

    Kind Regards

    Gary 


    Gary Simpson
    Friday, February 04, 2011 1:41 AM
  • Is there a workaround to change the colour with the XP visual style turned on??
    Wednesday, September 07, 2011 4:35 AM
  • Is there a workaround to change the colour with the XP visual style turned on??

    Using graphics and some code management, you could create a progressbar of your own design. Not too complicated.  
    Leon C Stanley - - A dinky di VB'er - -
    Wednesday, September 07, 2011 7:01 AM
  • The easiest way i found is to change the ForeColor of your progressbar and then go to properties and uncheck the Enable Xp visual styles chekbox in Application tab.
    Monday, July 09, 2012 10:06 AM
  • Here is a very good step by step tutorial (YouTube):

    http://goo.gl/1EuBR

    I hope someone find it useful.

    Code from tutorial:

    Public Class Form1
    
        Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            SendMessage(ProgressBar1.Handle, 1040, 3, 0)
            Timer1.Start()
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            ProgressBar1.Increment(1)
        End Sub
    End Class


    Regards.

    Sunday, June 09, 2013 4:43 PM
  • CodeProject has a pretty nice progressbar that you can change the color or make it multi-colored. You will need to download the project and unzip it in a place you want to keep it. Then you can add the dll to your toolbox so you can add one to any project you want just by dragging one onto your form. You can add it to your toolbox by going to your projects Design tab and then open the toolbox and right click. Then click Choose Items... When the window open click the browse button and browse to the (NeroBar) folder and then to the Release folder and double click the (JCS.Components.NeroBar.dll) file. Click Ok on the Choose Items window and your ready to add one to any project.  :)

    http://www.codeproject.com/Articles/31216/NeroBar

    Sunday, June 09, 2013 6:13 PM