p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# (http://p2p.wrox.com/forumdisplay.php?f=22)
-   -   About listbox (http://p2p.wrox.com/showthread.php?t=12403)

csc820203 April 29th, 2004 01:19 AM

About listbox
 
In ListBox
how can make the item I selected change for another color

thanks for your help


janeprime2001 April 29th, 2004 06:17 AM

Hi there!!

This is what I can come up with so far. You can use a string variable instead of a textbox.

I cannot find anything where you only change the color of the selected text but I will see if I can find anything else.

private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
    textBox1.Text = listBox1.Text;
    int count = 0;
    count = listBox1.SelectedIndex;
    if(count == listBox1.SelectedIndex)
    //if(listBox1.Text == textBox1.Text)
    {
        listBox1.BackColor = Color.Beige;
        listBox1.ForeColor = Color.Blue;
        textBox1.ForeColor = listBox1.ForeColor;
    }
}

Good Luck

Jan

dude_in_africa


All times are GMT -4. The time now is 07:20 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.