CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 1999
    Location
    London, England
    Posts
    9

    ListView Contols

    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
    [email protected]


  2. #2
    Join Date
    Feb 2000
    Location
    South Carolina, US
    Posts
    36

    Re: ListView Contols

    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



  3. #3
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: ListView Contols

    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...age=0&Limit=25


    Chris Eastwood

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured