Click to See Complete Forum and Search --> : ListView Contols


shaolin
February 16th, 2000, 07:34 AM
I am having a few problems with my list view control I want it to work like the playlist in winamp. I have given it a number of rows and columns to populate it and each row has a unique key the problems are:
1 I cannot change the colour of a single row of text
2 I cannot fix the last coulumn to the end of the list view and make any scrolling occur on the second list box

Side(fixed size),Filename(variable size),Length(fixed size)
what I want to do is fix the side column to the left of the list view and the length column to the right and then if the text in the filename text box is greater than the size then it will show the little ....

any help would be greatly appriciated (because the Visual basic books haven't been much help!)

please post any help to
shaolin_ob1@yahoo.com

Weasel
February 16th, 2000, 07:40 AM
A list box can't technically do this I believe, if you've seen multi-color before it was with a similar control, but not the same. You'll have to write your own. Look into the DrawText function of the API in Win32Api.txt

Use this and a few scroll bars and it should be doable.

Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long

Chris Eastwood
February 16th, 2000, 07:53 AM
If you are using VB6, then you can change the colour of each line in the listview by using the 'ForeColor' property of each ListItem, eg:


listview1.ListItems(1).ForeColor = vbRed




- you'll also need to change the '.ForeColor' property on the subitems for each list item.

If you are using VB5, then you'll have to implement custom-drawing of each item. It involves subclassing the owner of the listview (eg. Form, or Usercontrol) and catching and responding to various messages). I've written an example of this on the CodeGuru VB site - take a look under controls/Listview.

As for the resizing - I posted a reply to someone today with a similar problem, take a look at :

http://codeguru.developer.com/bbs/wt/showpost.pl?Board=vb&Number=15417&Searchpage=0&Limit=25


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb