المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ListView - Select ListViewItem



C# Programming
05-07-2009, 03:50 PM
Hi,

I have a list view with 5 columns and 4 items in that listView.

When i click on a row ( item) of that listViewi want the whole row to be highlighted blue , and if i select another row, what that it to be selected as well.
So basically i want it to look like the whole row is selected not just the first column item.
here is what i tried :
private void listView1_Click(object sender, EventArgs e)
{
for (int i = 0; i < listView1.Items.Count; i++)
{
if (listView1.Items[i].Selected == true)
{
listView1.Items[i].BackColor = Color.Blue;
}
}
}

BUT this works after I change the selection of the row! for example i select row 1 , and when i select row 2 , then row 1 is highlited . Why guys?
Any suggestions please?
Regards,
Alex

“Be the change you want to see in the world.”