CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: CListBox

  1. #1
    Join Date
    Apr 1999
    Posts
    2

    CListBox

    How to right align the text within CListBox


  2. #2
    Join Date
    Apr 1999
    Location
    CA, USA
    Posts
    78

    Re: CListBox

    If you use "Report" style for your ListBox, you can right align each column text except the first column. When you create the column headers for the ListCtrl, just use the following flag for the column alignment:

    LV_COLUMN lvc;
    lvc.mask = LVCF_FMT | LVCF_WIDTH |
    LVCF_TEXT | LVCF_SUBITEM;
    lvc.cx = 60; // width of first column
    lvc.fmt = LVCFMT_RIGHT; // align right

    for(int i=0; i < 4; i++){
    lvc.iSubItem = i;
    lvc.pszText = ColumnLabel[i];// Label
    m_list.InsertColumn(i,&lvc); // insert it
    }


    Hope this will help. Good luck.

    Lynx


  3. #3
    Join Date
    Apr 1999
    Posts
    24

    Re: CListBox

    Add WS_EX_RIGHT extended style to the ListBox.
    CListBox MyListBox;
    SetWindowLong(MyListBox.m_hWnd, GWL_EXSTYLE, WS_EX_RIGHT)
    Also from resources you can go to properties/Extedned Styles and set Right aligned text.



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