StrataFrame Forum

Add BackColor/ForeColor properties to the ListView columns

http://forum.strataframe.net/Topic23346.aspx

By Edhy Rijo - 6/4/2009

I would be really nice to be able to change column colors for the listview.
By Trent L. Taylor - 6/4/2009

Are you referring to the header or the area where the text is?  If you are referring to the text area, there is a new event called the RowPopulated (instead of RowPopulating) that gives you the entire column, list item ,etc.  So you could actually do this.

But here is a little sneak peek of something coming down the pike.  It won't be in the next release (but there may be some other goodies Wink ), but here is a StrataListView that will ultimately replace the current ListView.  The StrataListView is 100% written from scratch and so there will be a lot more flexibility.  But this is something fun to look forward to BigGrin

Notice that it will follow theme colors!  This will be in our medical app for a while before we release it...like we do most controls.  But once we work through the process it will make it into the framework.

By Edhy Rijo - 6/4/2009

Trent L. Taylor (06/04/2009)
Are you referring to the header or the area where the text is? If you are referring to the text area, there is a new event called the RowPopulated (instead of RowPopulating) that gives you the entire column, list item ,etc. So you could actually do this.


Super, could you provide a quick sample code on how to change the backcolor of a column?



But here is a little sneak peek of something coming down the pike. It won't be in the next release (but there may be some other goodies Wink ), but here is a StrataListView that will ultimately replace the current ListView. The StrataListView is 100% written from scratch and so there will be a lot more flexibility. But this is something fun to look forward to BigGrin


That is just awesome, can't wait to get this in the framework.
By Edhy Rijo - 6/5/2009

Trent,



In case you missed my response above, could you please provide a quick sample code on how to change the backcolor of a column in the ListView? I have tried different code and none worked.
By Trent L. Taylor - 6/5/2009

I was thinking the row, not the column. If you want to render the column, you will have to do an owner draw, which means you have to render all columns. It isn't that hard, but it will definitely be more work than just setting a property. This is something that will be in the future StrataListView control. Adding this logic to the existing ListView would require an entire Owner draw...thus using the new control would be more logical. Sorry Unsure
By Edhy Rijo - 6/5/2009

Trent L. Taylor (06/05/2009)
I was thinking the row, not the column.


I understand. Could you elaborate why would be use the RowPopulated instead of the RowPopulating?
By Trent L. Taylor - 6/6/2009

In short, it exposes the entire ListView Item so you can set anything on it you like such as the fore color, back color, etc.  You are given direct access to the ListViewItem properties.  That is really the only purpose.
By Edhy Rijo - 6/12/2009

Trent L. Taylor (06/05/2009)
... If you want to render the column, you will have to do an owner draw, which means you have to render all columns. It isn't that hard, but it will definitely be more work than just setting a property. This is something that will be in the future StrataListView control. Adding this logic to the existing ListView would require an entire Owner draw...thus using the new control would be more logical. Sorry Unsure




I am really in the need to add BackColor to a couple of columns in a several ListView, do have any sample or reference code that I may use as start point to try to get this done?
By Trent L. Taylor - 6/15/2009

There are a ton of them out on the web. Just search for ListView and OwnerDraw:



http://www.codeproject.com/KB/list/EXListView.aspx



http://www.experts-exchange.com/Programming/Languages/.NET/Q_20872868.html



This is just a function of the standard .NET ListView and handling that event. In the event you will be given the bounds, column and row information then you just render as you require. This does require some effort. This is also something that we do not intend to change on the existing ListView as it would require a lot of effort to make this a "global" resolution and our efforts would be better served on the new StrataListView control.
By Edhy Rijo - 6/15/2009

Thanks.