2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by finito
0

I am sure there are better ways but here is my method.

bool red = true;
            MyCon.Open();
            SqlDataReader search = search = new SqlCommand("SELECT something FROM somewhere WHERE condition", MyCon).ExecuteReader();
            ListViewItem temp;// = new ListViewItem();
            while (search.Read())
            {
                temp = new ListViewItem();
                temp.Text = search.GetString(0);
                temp.SubItems.Add(search.GetString(1));
               //etc.

                if (red)
                    temp.BackColor = Color.Red;
                else
                    temp.BackColor = Color.Green;

                red = !red; 

                listView1.Items.Add(temp);
            } 
            MyCon.Close();

Ofcourse you don't need to make it red and green.

Honestly red and Green are disgusting combo.

Edited by finito: n/a

0

thanx finito.
But in which event of listview control i have to write this code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.