List View Problem

This is a discussion on List View Problem within the Windows Programming forums, part of the Platform Specific Boards category; Hi there! In a List View I want to allign one of the columns to the right. So I wrote ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    List View Problem

    Hi there!

    In a List View I want to allign one of the columns to the right. So I wrote the code:
    Code:
    	hListView=::CreateWindowEx(NULL,WC_LISTVIEW,"#1006",
    		WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_EDITLABELS,
    		0,0,500,250,this->m_hWnd,NULL,theApp.m_hInstance,NULL);
    	lvColumn.pszText="Sum";
    	lvColumn.mask=LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_ORDER;
    	lvColumn.fmt=LVCFMT_RIGHT;
    	lvColumn.iOrder=0;
    	lvColumn.cx=50;
    	::SendMessage(hListView,LVM_INSERTCOLUMN,0,(LPARAM) &lvColumn);
    	lvColumn.pszText="Person";
    	lvColumn.mask=LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_ORDER;
    	lvColumn.iOrder=1;
    	lvColumn.cx=130;
    	lvColumn.fmt=LVCFMT_CENTER;
    	::SendMessage(hListView,LVM_INSERTCOLUMN,0,(LPARAM) &lvColumn);
    But all of the columns are left-alligned. Where am I wrong?

    Any suggestions are appreciated.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Check out MSDN.

    http://msdn.microsoft.com/library/de...s/lvcolumn.asp

    You need to createa temporary first column. For some reason, the first column in a list view is always left-aligned.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 03-02-2005, 01:45 AM
  2. problem with structures and linked list
    By Gkitty in forum C Programming
    Replies: 6
    Last Post: 12-12-2002, 05:40 PM
  3. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 04:20 PM
  4. Linked list with two class types within template.
    By SilasP in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2002, 05:13 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21