ListView Doubt

Discussion in 'MFC' started by hemanth.balaji, May 22, 2005.

  1. hemanth.balaji

    hemanth.balaji New Member

    Joined:
    May 22, 2005
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    How do you CENTER & BOLD the labels of the columns (i.e headings) using ListView. I did not understand the below found in MSDN..

    /*
    If a column is added to a list-view control with index 0 (the leftmost column) and with
    LVCFMT_RIGHT or LVCFMT_CENTER specified, the text is not right-aligned or centered. The text in the index 0 column is left-aligned. Therefore if you keep inserting columns with index 0, the text in all columns are left-aligned. If you want the first column to be
    right-aligned or centered you can make a dummy column, then insert one or more columns with index 1 or higher and specify the alignment you require. Finally delete the dummy column.
    */

    Also I want the last column to occupy the remaining width of the window even if resizing of the Main Window takes place.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    When you use the syntax for InsertColumn in a list view you have to specify the index at which that column is inserted. If you specify that as zero the Text align is Left by default and so you cannot Make it right or centered align. To make the left column left align inserting a dummy column with index zero and then at index 1 and then delete the column at index 0 provides us what we want. I hope this clears what you cannot understand from MSDN

    That can be done by specifying the column width same as the size of the listview.

    Thanks
    Shabbir Bhimani
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You have posted in the wrong forums. It should be in MFC/Win32 under Queries and expert comments and not under Codes and projects Section
     
  4. hemanth.balaji

    hemanth.balaji New Member

    Joined:
    May 22, 2005
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Its OK.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice