Using scrollbar - windows form backcolor changed

Posted by Naveenmanam under ASP.NET on 4/29/2010 | Views : 3209 | Status : [Member] | Replies : 1
Dear all,
i am using progress bar on c#.net windows form . and i need to change the
windows form backcolor as per progress bar move. as progress bar move 1% my window form back color fill up 1% it should be start filling from middle point to edge.

please provide me code of C#.net

NaveenKumar


Responses

Posted by: Naraayanan on: 1/2/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
It is an idea.Please try it.
In this Examples
The following controls and Forms used in my project.
Form -- 2
Backgroundworker -1
Progressbar -1
Button-1
Here my code:
Form 1
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.Threading;

namespace BackgroundworkerTesting
{
public partial class Form1 : Form
{
Form2 frm = new Form2();
public Form1()
{
InitializeComponent();
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
CounttoTime();
}

private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
frm.progressvalue = e.ProgressPercentage;
increasesizeofpanel();
}

private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
MessageBox.Show("Done");
frm.Close();

}

private void button1_Click(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
frm.ShowDialog();
}
private void CounttoTime()
{
int intiavalue = 100;
for (int cnt = 0; cnt < intiavalue; cnt =cnt +5)
{
Thread.Sleep(1000);
backgroundWorker1.ReportProgress(cnt);


}
}

public void increasesizeofpanel()
{
panel1.Width = panel1.Width + 50;
panel1.Height = panel1.Height + 50;
this.Controls.Add(panel1);
panel1.BackColor = Color.Red;
panel1.Dock = DockStyle.Top ;
}

}
}

Form2
public int progressvalue

{
get
{
return this.progressBar1.Value;
}
set
{
progressBar1.Value = value;
}
}


Note: it is my Idea.Change your requirements



Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Naveenmanam, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response