Forum  Core :: SDK (Vi...   How do I...?  Alternate background color in a listview
Previous Previous
 
Next Next
New Post 7/22/2009 1:22 PM
  ben75020
16 posts
No Ranking


Alternate background color in a listview 

Hi All,

How to set the backcolor on a listview on alternating rows ? Currently I am changing the backcolor property but it doesnt seem to work.

(Silverlight 2 / WebGui 6.3.8)

Any idea ?

 

 
New Post 7/30/2009 4:18 AM
  ori.cohen
4390 posts
1st Level Poster




Re: Alternate background color in a listview 

Hello,

I think that what I would do is to create a custom ListView - a class that would inherit from the ListView class, implement one or more style properties for alternate rows and have every second row in the ListView get the style from these properties and not from the default.

Regards,

Ori Cohen
Support Manager, the Visual WebGui team

 
New Post 7/30/2009 2:10 PM
  ben75020
16 posts
No Ranking


Re: Alternate background color in a listview 
Modified By ben75020  on 7/30/2009 5:12:35 PM)

Hi Ori,

I use the code below:

var i = 0;

foreach (var item in itemList)

{

...

var sourceitem = new ListViewItem(new[] ...

                    if (i++ % 2 == 1)

                           sourceitem.BackColor = Color.LightBlue;                   

....

}

The listview item back color still white. Is it a bug ?

Regards,

Benjamin

 
New Post 8/3/2009 5:32 PM
  palli
11824 posts
1st Level Poster




Re: Alternate background color in a listview 
Modified By palli  on 8/3/2009 8:33:05 PM)

Hi Benjamin,

If I would guess what you are doing, it seems like you are constructing the listview and coloring the rows while building. If so, you are bound to have problems, as when someone clicks the column header, the ListView gets sorted and everything goes nuts. That is why Ori suggested a custom ListView that would account for all that.

I think it would help us see the whole picture if you posted a more complete code, or better yet, create a most minimal application that demonstrates what you are doing and then send your application to support [at] visualwebgui [dot] com (see my signature) with a link to this forum thread, along with some description about your approach.

Please also clean the solution before compressing it and reply to this post after sending, so we will know to check for your support request.

If connection to database is needed, please make sure you will either be using all memory based data or the MSSQL Northwind sample database for your connection(s) or preferably change your application to work without a database.

Remember to include information about what VWG version you are using, as well as you Visual Studio version+type and operating system version.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 8/17/2009 3:07 AM
  ben75020
16 posts
No Ranking


Re: Alternate background color in a listview 

Hi Palli,

You can reproduce the issue with "ListViewControl" in the catalog sample. The backcolor property doesn't apply to listviewItem even i set UseItemStyleForSubItems to true. Works fine with wgx. (Silverlight 3/ VWG 6.3.9).

Regards,

Benjamin.

 
Previous Previous
 
Next Next
  Forum  Core :: SDK (Vi...   How do I...?  Alternate background color in a listview
Assessment Bottom
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS