locked
Beginner in Visual C#, simple question about label & progress bar? RRS feed

  • Question

  • Ive been learning visual c# for less than a month only. I just made a small app, somewhat a poll. And Ive everything good and set, its just that the vote results are just in number(labels), instead I'd want it to look more like a poll with the labels coming along with a progress bar. So whenever each vote is clicked, the labels increase by 1 and the progress bar moves too.. Can u tell me what to do here?

    Here's a screenshot. http://img135.imageshack.us/i/23501308.png/

    The one marked red, are the labels.. I want it to have a progress bar too..

    Thanks in advance. Cheers :)

    Monday, April 4, 2011 7:54 PM

Answers

  • Hi D-X69,

    Based on your description, I think you can use the panel instead of the ProgressBar. You can set he panel's size manually and set he panel BackGround color. Here is my sample code:

    // in the designer , I add five radiobuttons, five panels, two groupboxes and a button.
    
    namespace WFApp
    {
      partial class TestForm
      {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
    
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
          if (disposing && (components != null))
          {
            components.Dispose();
          }
          base.Dispose(disposing);
        }
    
        #region Windows Form Designer generated code
    
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
          this.printDocument1 = new System.Drawing.Printing.PrintDocument();
          this.groupBox1 = new System.Windows.Forms.GroupBox();
          this.radioButton5 = new System.Windows.Forms.RadioButton();
          this.radioButton4 = new System.Windows.Forms.RadioButton();
          this.radioButton3 = new System.Windows.Forms.RadioButton();
          this.radioButton2 = new System.Windows.Forms.RadioButton();
          this.radioButton1 = new System.Windows.Forms.RadioButton();
          this.groupBox2 = new System.Windows.Forms.GroupBox();
          this.button1 = new System.Windows.Forms.Button();
          this.panel1 = new System.Windows.Forms.Panel();
          this.panel2 = new System.Windows.Forms.Panel();
          this.panel3 = new System.Windows.Forms.Panel();
          this.panel4 = new System.Windows.Forms.Panel();
          this.panel5 = new System.Windows.Forms.Panel();
          this.groupBox1.SuspendLayout();
          this.groupBox2.SuspendLayout();
          this.SuspendLayout();
          // 
          // groupBox1
          // 
          this.groupBox1.Controls.Add(this.radioButton5);
          this.groupBox1.Controls.Add(this.radioButton4);
          this.groupBox1.Controls.Add(this.radioButton3);
          this.groupBox1.Controls.Add(this.radioButton2);
          this.groupBox1.Controls.Add(this.radioButton1);
          this.groupBox1.Location = new System.Drawing.Point(13, 29);
          this.groupBox1.Name = "groupBox1";
          this.groupBox1.Size = new System.Drawing.Size(208, 205);
          this.groupBox1.TabIndex = 0;
          this.groupBox1.TabStop = false;
          this.groupBox1.Text = "Teams";
          // 
          // radioButton5
          // 
          this.radioButton5.AutoSize = true;
          this.radioButton5.Location = new System.Drawing.Point(59, 158);
          this.radioButton5.Name = "radioButton5";
          this.radioButton5.Size = new System.Drawing.Size(85, 17);
          this.radioButton5.TabIndex = 4;
          this.radioButton5.TabStop = true;
          this.radioButton5.Text = "radioButton5";
          this.radioButton5.UseVisualStyleBackColor = true;
          // 
          // radioButton4
          // 
          this.radioButton4.AutoSize = true;
          this.radioButton4.Location = new System.Drawing.Point(59, 126);
          this.radioButton4.Name = "radioButton4";
          this.radioButton4.Size = new System.Drawing.Size(85, 17);
          this.radioButton4.TabIndex = 3;
          this.radioButton4.TabStop = true;
          this.radioButton4.Text = "radioButton4";
          this.radioButton4.UseVisualStyleBackColor = true;
          // 
          // radioButton3
          // 
          this.radioButton3.AutoSize = true;
          this.radioButton3.Location = new System.Drawing.Point(59, 94);
          this.radioButton3.Name = "radioButton3";
          this.radioButton3.Size = new System.Drawing.Size(85, 17);
          this.radioButton3.TabIndex = 2;
          this.radioButton3.TabStop = true;
          this.radioButton3.Text = "radioButton3";
          this.radioButton3.UseVisualStyleBackColor = true;
          // 
          // radioButton2
          // 
          this.radioButton2.AutoSize = true;
          this.radioButton2.Location = new System.Drawing.Point(59, 62);
          this.radioButton2.Name = "radioButton2";
          this.radioButton2.Size = new System.Drawing.Size(85, 17);
          this.radioButton2.TabIndex = 1;
          this.radioButton2.TabStop = true;
          this.radioButton2.Text = "radioButton2";
          this.radioButton2.UseVisualStyleBackColor = true;
          // 
          // radioButton1
          // 
          this.radioButton1.AutoSize = true;
          this.radioButton1.Location = new System.Drawing.Point(59, 30);
          this.radioButton1.Name = "radioButton1";
          this.radioButton1.Size = new System.Drawing.Size(85, 17);
          this.radioButton1.TabIndex = 0;
          this.radioButton1.TabStop = true;
          this.radioButton1.Text = "radioButton1";
          this.radioButton1.UseVisualStyleBackColor = true;
          // 
          // groupBox2
          // 
          this.groupBox2.Controls.Add(this.panel5);
          this.groupBox2.Controls.Add(this.panel4);
          this.groupBox2.Controls.Add(this.panel3);
          this.groupBox2.Controls.Add(this.panel2);
          this.groupBox2.Controls.Add(this.panel1);
          this.groupBox2.Location = new System.Drawing.Point(227, 29);
          this.groupBox2.Name = "groupBox2";
          this.groupBox2.Size = new System.Drawing.Size(118, 205);
          this.groupBox2.TabIndex = 1;
          this.groupBox2.TabStop = false;
          this.groupBox2.Text = "Votes";
          // 
          // button1
          // 
          this.button1.Location = new System.Drawing.Point(264, 250);
          this.button1.Name = "button1";
          this.button1.Size = new System.Drawing.Size(75, 23);
          this.button1.TabIndex = 2;
          this.button1.Text = "Vote";
          this.button1.UseVisualStyleBackColor = true;
          this.button1.Click += new System.EventHandler(this.button1_Click);
          // 
          // panel1
          // 
          this.panel1.Location = new System.Drawing.Point(6, 24);
          this.panel1.Name = "panel1";
          this.panel1.Size = new System.Drawing.Size(106, 23);
          this.panel1.TabIndex = 3;
          // 
          // panel2
          // 
          this.panel2.Location = new System.Drawing.Point(6, 56);
          this.panel2.Name = "panel2";
          this.panel2.Size = new System.Drawing.Size(106, 23);
          this.panel2.TabIndex = 4;
          // 
          // panel3
          // 
          this.panel3.Location = new System.Drawing.Point(6, 88);
          this.panel3.Name = "panel3";
          this.panel3.Size = new System.Drawing.Size(106, 23);
          this.panel3.TabIndex = 4;
          // 
          // panel4
          // 
          this.panel4.Location = new System.Drawing.Point(6, 120);
          this.panel4.Name = "panel4";
          this.panel4.Size = new System.Drawing.Size(106, 23);
          this.panel4.TabIndex = 4;
          // 
          // panel5
          // 
          this.panel5.Location = new System.Drawing.Point(6, 152);
          this.panel5.Name = "panel5";
          this.panel5.Size = new System.Drawing.Size(106, 23);
          this.panel5.TabIndex = 4;
          // 
          // TestForm
          // 
          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
          this.ClientSize = new System.Drawing.Size(372, 285);
          this.Controls.Add(this.button1);
          this.Controls.Add(this.groupBox2);
          this.Controls.Add(this.groupBox1);
          this.KeyPreview = true;
          this.Name = "TestForm";
          this.Text = "TestForm";
          this.groupBox1.ResumeLayout(false);
          this.groupBox1.PerformLayout();
          this.groupBox2.ResumeLayout(false);
          this.ResumeLayout(false);
    
        }
    
        #endregion
    
        private System.Drawing.Printing.PrintDocument printDocument1;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.RadioButton radioButton5;
        private System.Windows.Forms.RadioButton radioButton4;
        private System.Windows.Forms.RadioButton radioButton3;
        private System.Windows.Forms.RadioButton radioButton2;
        private System.Windows.Forms.RadioButton radioButton1;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Panel panel5;
        private System.Windows.Forms.Panel panel4;
        private System.Windows.Forms.Panel panel3;
        private System.Windows.Forms.Panel panel2;
    
    
      }
    }
    
    // in the testform
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Collections;
    using System.IO;
    using System.Drawing.Printing;
    using System.Data.SqlTypes;
    using System.Text.RegularExpressions;
    using System.Diagnostics;
    using System.Configuration;
    using System.Xml.Serialization;
    using System.DirectoryServices.ActiveDirectory;
    using System.Threading;
    using System.DirectoryServices;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    using System.Management;
    using System.Security.Cryptography.X509Certificates;
    using System.Net;
    using Microsoft.Win32;
    using System.Security.AccessControl;
    using System.Security.Principal;
    using System.Resources;
    using System.Reflection;
    
    namespace WFApp
    {
      public partial class TestForm : Form
      {
    
        public TestForm()
        {
          InitializeComponent();
        }
    
        private int count1 = 0;
        private int count2 = 0;
        private int count3 = 0;
        private int count4 = 0;
        private int count5 = 0;
    
        private void button1_Click(object sender, EventArgs e)
        {
          if (this.radioButton1.Checked == true)
          {
            this.panel1.BackColor = Color.Red;
            this.panel1.Size = new Size(++count1,this.panel1.Size.Height);
          }
          else if (this.radioButton2.Checked == true)
          {
            this.panel2.BackColor = Color.Red;
            this.panel2.Size = new Size(++count2, this.panel1.Size.Height); 
          }
          else if (this.radioButton3.Checked == true)
          {
            this.panel3.BackColor = Color.Red;
            this.panel3.Size = new Size(++count3, this.panel1.Size.Height); 
          }
          else if (this.radioButton4.Checked == true)
          {
            this.panel4.BackColor = Color.Red;
            this.panel4.Size = new Size(++count4, this.panel1.Size.Height); 
          }
          else if (this.radioButton5.Checked == true)
          {
            this.panel5.BackColor = Color.Red;
            this.panel5.Size = new Size(++count5, this.panel1.Size.Height); 
          }
        }
      }
    }
    The code can work well. You can have a try. If any misunderstanding, please feel free let me know. Thanks.
    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aspen VJ Tuesday, April 12, 2011 1:22 AM
    Wednesday, April 6, 2011 7:42 AM
  • Hi D,

    Three minutes ago I made this sample for the Windows Forms forum, maybe you can use it as well.

    It is still in under my clipboard.

    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    namespace WindowsFormsApplication8
    {
      public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
          for (int j = 0; j < 3; j++)
          {
            for (int i = 0; i < 8; i++)
            {
              Button bt = new Button()
              {
                Location = new System.Drawing.Point(j * 48, i * 24),
                Size = new Size(48, 24),
                TabIndex = i,
                Text = (i + 1 + j * 8).ToString(),
                Tag = i.ToString()
              };
              bt.Click += ClickButton;
              Controls.Add(bt);
            }
          }
        }
        private void ClickButton(object sender, EventArgs e)
        {
          MessageBox.Show("Clicked was " +
          ((Button)sender).Tag.ToString());
        }
      }
    }
    
    

    It is not the progress bar but at least you can make a clickboard with that.

     


    Success
    Cor
    Wednesday, April 6, 2011 7:44 AM

All replies

  • Ive been learning visual c# for less than a month only. I just made a small app, somewhat a poll. And Ive everything good and set, its just that the vote results are just in number(labels), instead I'd want it to look more like a poll with the labels coming along with a progress bar. So whenever each vote is clicked, the labels increase by 1 and the progress bar moves too.. Can u tell me what to do here?

    Here's a screenshot. http://img135.imageshack.us/i/23501308.png/

    The one marked red, are the labels.. I want it to have a progress bar too..

    Thanks in advance. Cheers :)



    • Merged by Aspen VJ Wednesday, April 6, 2011 6:26 AM duplicate
    Monday, April 4, 2011 7:28 PM
  • If I posted in the wrong section, I'd apologize and hope moderators will move it to the appropriate section.
    Monday, April 4, 2011 7:31 PM
  • I think I found the right place (Visual C# General) to ask my question, please remove this thread.
    • Proposed as answer by Seabass008 Tuesday, April 5, 2011 4:18 PM
    Monday, April 4, 2011 7:55 PM
  •   this.progressBar1.Value = 0;
      this.progressBar1.Minimum = 0;
      this.progressBar1.Maximum = 100;
      this.progressBar1.Step = 1;
      this.progressBar1.PerformStep();
    


    Sounds like you want to work with the progressBar.value it has set and get.  the .step and .performstep() will only be required if you want to add some moving graphics.

     

    sound right?


    CountryStyle

    PS: the express forums would have worked too.

    Tuesday, April 5, 2011 1:20 AM
  • As Country Style said you may add a progress bar near the vote label. But you may not know the maximum of the progress bar. The maximum would be the total votes for all the teams. Then the progressbar value would be the percentage of vote for this team to the toal votes. Use the progress bar's value property to set this percentage. In this case no need to performstep.

    You can get a look like this http://www.codeproject.com/Surveys/1140/Do-you-have-titles-in-your-workplace.aspx

    Tuesday, April 5, 2011 4:32 AM
  • Sorry I'm a total noob in C# I gotta be honest, I have no clue what you nor country style is trying to tell me to do. And about the total votes, is it okay if I omit to show the total number of votes, thou the percentage is counted through all the votes. And I think you should check out what ive done so far. And tell me what to add and where to add.

    Here's a link to it:

    http://www.mediafire.com/?i5p8gf7uot41my7

     

    Thank you!


    Tuesday, April 5, 2011 5:29 AM
  • It would be easier for us if that upload was the sourcecode instead of just the binary =) then we could give more concise code examples.

    What CountryStyle is talking about are the Properties for the ProgressBar control class. See - http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.aspx   (I googled for ".NET ProgressBar" to find that).

    Whenever the user clicks the Vote button, you would want to perform some code like what CountryStyle had. ProgressBar1 through to ProgressBar6 (one for each team) controls would all have their values updated to represent the percentage of how many votes that team has.

    That's all I can say for the theory - if you want code examples, I'll need to look at the source.

    Tuesday, April 5, 2011 12:53 PM
  • Just place a ProgressBar control on your form.  Set it Maximum value to something like 100.  Then just increment the value by 1 each time the vote increases.  If you know the maximum number of votes, set the progress bar's maximum to that value.
    Tuesday, April 5, 2011 5:48 PM
  • Hi D-X69,

    Based on your description, I think you can use the panel instead of the ProgressBar. You can set he panel's size manually and set he panel BackGround color. Here is my sample code:

    // in the designer , I add five radiobuttons, five panels, two groupboxes and a button.
    
    namespace WFApp
    {
      partial class TestForm
      {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
    
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
          if (disposing && (components != null))
          {
            components.Dispose();
          }
          base.Dispose(disposing);
        }
    
        #region Windows Form Designer generated code
    
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
          this.printDocument1 = new System.Drawing.Printing.PrintDocument();
          this.groupBox1 = new System.Windows.Forms.GroupBox();
          this.radioButton5 = new System.Windows.Forms.RadioButton();
          this.radioButton4 = new System.Windows.Forms.RadioButton();
          this.radioButton3 = new System.Windows.Forms.RadioButton();
          this.radioButton2 = new System.Windows.Forms.RadioButton();
          this.radioButton1 = new System.Windows.Forms.RadioButton();
          this.groupBox2 = new System.Windows.Forms.GroupBox();
          this.button1 = new System.Windows.Forms.Button();
          this.panel1 = new System.Windows.Forms.Panel();
          this.panel2 = new System.Windows.Forms.Panel();
          this.panel3 = new System.Windows.Forms.Panel();
          this.panel4 = new System.Windows.Forms.Panel();
          this.panel5 = new System.Windows.Forms.Panel();
          this.groupBox1.SuspendLayout();
          this.groupBox2.SuspendLayout();
          this.SuspendLayout();
          // 
          // groupBox1
          // 
          this.groupBox1.Controls.Add(this.radioButton5);
          this.groupBox1.Controls.Add(this.radioButton4);
          this.groupBox1.Controls.Add(this.radioButton3);
          this.groupBox1.Controls.Add(this.radioButton2);
          this.groupBox1.Controls.Add(this.radioButton1);
          this.groupBox1.Location = new System.Drawing.Point(13, 29);
          this.groupBox1.Name = "groupBox1";
          this.groupBox1.Size = new System.Drawing.Size(208, 205);
          this.groupBox1.TabIndex = 0;
          this.groupBox1.TabStop = false;
          this.groupBox1.Text = "Teams";
          // 
          // radioButton5
          // 
          this.radioButton5.AutoSize = true;
          this.radioButton5.Location = new System.Drawing.Point(59, 158);
          this.radioButton5.Name = "radioButton5";
          this.radioButton5.Size = new System.Drawing.Size(85, 17);
          this.radioButton5.TabIndex = 4;
          this.radioButton5.TabStop = true;
          this.radioButton5.Text = "radioButton5";
          this.radioButton5.UseVisualStyleBackColor = true;
          // 
          // radioButton4
          // 
          this.radioButton4.AutoSize = true;
          this.radioButton4.Location = new System.Drawing.Point(59, 126);
          this.radioButton4.Name = "radioButton4";
          this.radioButton4.Size = new System.Drawing.Size(85, 17);
          this.radioButton4.TabIndex = 3;
          this.radioButton4.TabStop = true;
          this.radioButton4.Text = "radioButton4";
          this.radioButton4.UseVisualStyleBackColor = true;
          // 
          // radioButton3
          // 
          this.radioButton3.AutoSize = true;
          this.radioButton3.Location = new System.Drawing.Point(59, 94);
          this.radioButton3.Name = "radioButton3";
          this.radioButton3.Size = new System.Drawing.Size(85, 17);
          this.radioButton3.TabIndex = 2;
          this.radioButton3.TabStop = true;
          this.radioButton3.Text = "radioButton3";
          this.radioButton3.UseVisualStyleBackColor = true;
          // 
          // radioButton2
          // 
          this.radioButton2.AutoSize = true;
          this.radioButton2.Location = new System.Drawing.Point(59, 62);
          this.radioButton2.Name = "radioButton2";
          this.radioButton2.Size = new System.Drawing.Size(85, 17);
          this.radioButton2.TabIndex = 1;
          this.radioButton2.TabStop = true;
          this.radioButton2.Text = "radioButton2";
          this.radioButton2.UseVisualStyleBackColor = true;
          // 
          // radioButton1
          // 
          this.radioButton1.AutoSize = true;
          this.radioButton1.Location = new System.Drawing.Point(59, 30);
          this.radioButton1.Name = "radioButton1";
          this.radioButton1.Size = new System.Drawing.Size(85, 17);
          this.radioButton1.TabIndex = 0;
          this.radioButton1.TabStop = true;
          this.radioButton1.Text = "radioButton1";
          this.radioButton1.UseVisualStyleBackColor = true;
          // 
          // groupBox2
          // 
          this.groupBox2.Controls.Add(this.panel5);
          this.groupBox2.Controls.Add(this.panel4);
          this.groupBox2.Controls.Add(this.panel3);
          this.groupBox2.Controls.Add(this.panel2);
          this.groupBox2.Controls.Add(this.panel1);
          this.groupBox2.Location = new System.Drawing.Point(227, 29);
          this.groupBox2.Name = "groupBox2";
          this.groupBox2.Size = new System.Drawing.Size(118, 205);
          this.groupBox2.TabIndex = 1;
          this.groupBox2.TabStop = false;
          this.groupBox2.Text = "Votes";
          // 
          // button1
          // 
          this.button1.Location = new System.Drawing.Point(264, 250);
          this.button1.Name = "button1";
          this.button1.Size = new System.Drawing.Size(75, 23);
          this.button1.TabIndex = 2;
          this.button1.Text = "Vote";
          this.button1.UseVisualStyleBackColor = true;
          this.button1.Click += new System.EventHandler(this.button1_Click);
          // 
          // panel1
          // 
          this.panel1.Location = new System.Drawing.Point(6, 24);
          this.panel1.Name = "panel1";
          this.panel1.Size = new System.Drawing.Size(106, 23);
          this.panel1.TabIndex = 3;
          // 
          // panel2
          // 
          this.panel2.Location = new System.Drawing.Point(6, 56);
          this.panel2.Name = "panel2";
          this.panel2.Size = new System.Drawing.Size(106, 23);
          this.panel2.TabIndex = 4;
          // 
          // panel3
          // 
          this.panel3.Location = new System.Drawing.Point(6, 88);
          this.panel3.Name = "panel3";
          this.panel3.Size = new System.Drawing.Size(106, 23);
          this.panel3.TabIndex = 4;
          // 
          // panel4
          // 
          this.panel4.Location = new System.Drawing.Point(6, 120);
          this.panel4.Name = "panel4";
          this.panel4.Size = new System.Drawing.Size(106, 23);
          this.panel4.TabIndex = 4;
          // 
          // panel5
          // 
          this.panel5.Location = new System.Drawing.Point(6, 152);
          this.panel5.Name = "panel5";
          this.panel5.Size = new System.Drawing.Size(106, 23);
          this.panel5.TabIndex = 4;
          // 
          // TestForm
          // 
          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
          this.ClientSize = new System.Drawing.Size(372, 285);
          this.Controls.Add(this.button1);
          this.Controls.Add(this.groupBox2);
          this.Controls.Add(this.groupBox1);
          this.KeyPreview = true;
          this.Name = "TestForm";
          this.Text = "TestForm";
          this.groupBox1.ResumeLayout(false);
          this.groupBox1.PerformLayout();
          this.groupBox2.ResumeLayout(false);
          this.ResumeLayout(false);
    
        }
    
        #endregion
    
        private System.Drawing.Printing.PrintDocument printDocument1;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.RadioButton radioButton5;
        private System.Windows.Forms.RadioButton radioButton4;
        private System.Windows.Forms.RadioButton radioButton3;
        private System.Windows.Forms.RadioButton radioButton2;
        private System.Windows.Forms.RadioButton radioButton1;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Panel panel5;
        private System.Windows.Forms.Panel panel4;
        private System.Windows.Forms.Panel panel3;
        private System.Windows.Forms.Panel panel2;
    
    
      }
    }
    
    // in the testform
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Collections;
    using System.IO;
    using System.Drawing.Printing;
    using System.Data.SqlTypes;
    using System.Text.RegularExpressions;
    using System.Diagnostics;
    using System.Configuration;
    using System.Xml.Serialization;
    using System.DirectoryServices.ActiveDirectory;
    using System.Threading;
    using System.DirectoryServices;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    using System.Management;
    using System.Security.Cryptography.X509Certificates;
    using System.Net;
    using Microsoft.Win32;
    using System.Security.AccessControl;
    using System.Security.Principal;
    using System.Resources;
    using System.Reflection;
    
    namespace WFApp
    {
      public partial class TestForm : Form
      {
    
        public TestForm()
        {
          InitializeComponent();
        }
    
        private int count1 = 0;
        private int count2 = 0;
        private int count3 = 0;
        private int count4 = 0;
        private int count5 = 0;
    
        private void button1_Click(object sender, EventArgs e)
        {
          if (this.radioButton1.Checked == true)
          {
            this.panel1.BackColor = Color.Red;
            this.panel1.Size = new Size(++count1,this.panel1.Size.Height);
          }
          else if (this.radioButton2.Checked == true)
          {
            this.panel2.BackColor = Color.Red;
            this.panel2.Size = new Size(++count2, this.panel1.Size.Height); 
          }
          else if (this.radioButton3.Checked == true)
          {
            this.panel3.BackColor = Color.Red;
            this.panel3.Size = new Size(++count3, this.panel1.Size.Height); 
          }
          else if (this.radioButton4.Checked == true)
          {
            this.panel4.BackColor = Color.Red;
            this.panel4.Size = new Size(++count4, this.panel1.Size.Height); 
          }
          else if (this.radioButton5.Checked == true)
          {
            this.panel5.BackColor = Color.Red;
            this.panel5.Size = new Size(++count5, this.panel1.Size.Height); 
          }
        }
      }
    }
    The code can work well. You can have a try. If any misunderstanding, please feel free let me know. Thanks.
    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aspen VJ Tuesday, April 12, 2011 1:22 AM
    Wednesday, April 6, 2011 7:42 AM
  • Hi D,

    Three minutes ago I made this sample for the Windows Forms forum, maybe you can use it as well.

    It is still in under my clipboard.

    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    namespace WindowsFormsApplication8
    {
      public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
          for (int j = 0; j < 3; j++)
          {
            for (int i = 0; i < 8; i++)
            {
              Button bt = new Button()
              {
                Location = new System.Drawing.Point(j * 48, i * 24),
                Size = new Size(48, 24),
                TabIndex = i,
                Text = (i + 1 + j * 8).ToString(),
                Tag = i.ToString()
              };
              bt.Click += ClickButton;
              Controls.Add(bt);
            }
          }
        }
        private void ClickButton(object sender, EventArgs e)
        {
          MessageBox.Show("Clicked was " +
          ((Button)sender).Tag.ToString());
        }
      }
    }
    
    

    It is not the progress bar but at least you can make a clickboard with that.

     


    Success
    Cor
    Wednesday, April 6, 2011 7:44 AM