There was an error in this gadget

Search This Blog

Random Color Generator in C# .net

Random color generator

This dll helps to generate random color in windows as well as web application.

This dll helps you to generate random colors out of 10 million colors.
There are 2 methods
    1 NextColor()
    2 RotateBackColor(control, interval) +1 overload method
    3 RotateForeColor(control,interval) +1 overload method

Add this dll  to your project and you can access this methods.
Download this dll here RandomColorGenerator.dll

Lets take a look at both this methods one by one.

NextColor()


This method will generate Random color.

Example:

private void changeColorToolStripMenuItem_Click(object sender, EventArgs e)
{
            this.BackColor = RandomColorGenerator.NextColor();
}

This will change the back color of form wherever the above event is executed

Same way you can set random color to any of the control you want.

protected void changeLabelColor(object sender, EventArgs e)
{
            Label1.BackColor = RandomColorGenerator.NextColor();
}


RotateBackColor(control, interval)

This method changes color of specified control for every specified time interval.

Example

private void changeColorToolStripMenuItem_Click(object sender, EventArgs e)
{
    RandomColorGenerator.RotateBackColor(this, 2000);
}

This code will change the background color of Form for every 2 second

Same we can give multiple controls to change their Background for every specified time.

private void RotateColor_Click(object sender, EventArgs e)
{
    Control[] c = new[] { label1, label2, label3 };
    RandomColorGenerator.RotateBackColor(c, 2000);
}

This code will change the background color of label1,label2 and label3 for every 2 second.

RotateForeColor(control, interval)

This method changes ForeColor of specified control for every specified time interval.

Example

private void changeForeColorToolStripMenuItem_Click(object sender, EventArgs e)
{
    RandomColorGenerator.RotateForeColor(label1, 2000);
}

This code will change the background color of label1 for every 2 second

Same we can give multiple controls to change their ForeColor for every specified time.

private void RotateForeColor_Click(object sender, EventArgs e)
{
    Control[] c = new[] { label1, label2, label3 };
    RandomColorGenerator.RotateForeColor(c, 2000);
}

This code will change the ForeColor of label1,label2 and label3 for every 2 second.

Drivers & Support