Forum guidelines
AuthorQuestion
changing color of list view cell using C#
Posted By ishika singh on 27 Aug 2009
hi, i want to change the color of list view on some particular cell using C# in windows application for that i tried

lvwNotice.Items[cntr].SubItems[5].BackColor = System.Drawing.Color.Red;
lvwNotice.Items[cntr].SubItems[5].Font.Bold = 1;
 
but it doesn't work, where i m doing wrong, or there is any other method for changing the color, font, style of listview cell value.

thanks

AuthorReply
Re: changing color of list view cell using C#
Posted By Niradhip Chakraborty on 27 Aug 2009  

 
Try This.
listView1.Items[0].BackColor = System.Drawing.Color.Green;

Regards,
Niradhip(James Hetfield)
MCP,MVC,MVP(Mindcracker)
--------------------------------------------------------------------------------------
Please remember to click “Do you like this answer” on the post that helps you.
Re: changing color of list view cell using C#
Posted By Kirtan Patel on 27 Aug 2009  
Hi ishika ,

Here is Solution to your Problem

don't forget to mark "do you like answer" please it will give me some credits :)




private void button1_Click(object sender, EventArgs e)

        {

            string[] s = { "Hello", "hello" };

 

            ListViewItem lvi = new ListViewItem(s);

 

            listView1.Items.Add(lvi);

 

             //this is very Important

            listView1.Items[0].UseItemStyleForSubItems = false;


            // Now you can Change the Particular Cell Property of Style

           listView1.Items[0].SubItems[1].BackColor = Color.Red;

 

        }



MY BLOG ( www.codestructs.com ) | MY SITE

Kirtan
 Patel   BCA   MCA (SEMESTER-IV)  MINDCRACKER MVP WEB HACKER



Re: changing color of list view cell using C#
Posted By ishika singh on 29 Aug 2009  
thanks, it's working,

Aspose File APIs

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.