0% found this document useful (0 votes)
9 views1 page

Coding March 21 Hehe

Uploaded by

ccssyv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Coding March 21 Hehe

Uploaded by

ccssyv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Click listbox1 then find databindings then items


2. FORM
listBox1.Items.Add("RED");
listBox1.Items.Add("YELLOW");
listBox1.Items.Add("BLUE");

3. BUTTON (yung may add)

listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";

CHANGE COLOR FORM

private void button3_Click(object sender, EventArgs e)


{
if (listBox1.SelectedIndex == 0)
this.BackColor = Color.Red;

if (listBox1.SelectedIndex == 1)
this.BackColor = Color.Yellow;

if (listBox1.SelectedIndex == 2)
this.BackColor = Color.Blue;

if (listBox1.SelectedIndex == 3)
this.BackColor = Color.Pink;

if (listBox1.SelectedIndex == 4)
this.BackColor = Color.Black;
}

CHANGE COLOR LISTBOX

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)


{
if (listBox1.SelectedIndex == 0)
listBox1.BackColor = Color.Red;

if (listBox1.SelectedIndex == 1)
listBox1.BackColor = Color.Yellow;

if (listBox1.SelectedIndex == 2)
listBox1.BackColor = Color.Blue;

if (listBox1.SelectedIndex == 3)
listBox1.BackColor = Color.Pink;

if (listBox1.SelectedIndex == 4)
listBox1.BackColor = Color.Black;
}

You might also like