Wednesday, September 9, 2009

Generate Random Number22



namespace RandomNoGenerate2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

int min, max, val = 0;
Random rdm;
bool b;
private void Form2_Load(object sender, EventArgs e)
{
for (int i = 1; i <= 30; i++)
{
comboBox1.Items.Add(i);
}

randomnoforcombo5();
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
rdm = new Random();
min = Convert.ToInt32(txt_min.Text);
max = Convert.ToInt32(txt_max.Text);
val = rdm.Next(min, max);
comboBox1.Text = val.ToString();
}

private void link_Check_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
for (int i = 0; i < listBox2.Items.Count; i++)
{
if (comboBox2.Text == listBox2.Items[i].ToString())
{
comboBox2.BackColor = Color.Tomato;
return;
}
}
listBox2.Items.Add(comboBox2.Text);
comboBox2.BackColor = Color.White;
}

private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < listBox3.Items.Count; i++)
{
if (comboBox3.Text == listBox3.Items[i].ToString())
{
comboBox3.BackColor = Color.Tomato;
return;
}
}
listBox3.Items.Add(comboBox3.Text);
comboBox3.BackColor = Color.White;
}

private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
listBox4.Items.Add(comboBox4.Text);
comboBox4.Items.Remove(comboBox4.Text);
}

private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Form2_Load(sender, e);
}
private void randomnoforcombo5()
{
rdm = new Random();
min = Convert.ToInt32(txt_min.Text);
max = Convert.ToInt32(txt_max.Text);
val = rdm.Next(min, max);
comboBox5.Text = val.ToString();
}
}
}

No comments:

Post a Comment

Followers