CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    United Kingdom
    Posts
    136

    Right aligning first column in CListCtrl

    How do I make the first (i.e. leftmost) column right-align the text in it? This would be useful for a list of numbers. According to the help, CListCtrl's first column must be left-aligned. Any ideas?


  2. #2
    Join Date
    May 1999
    Location
    Canada
    Posts
    36

    Re: Right aligning first column in CListCtrl

    The solution is to set the column again after it has been inserted.

    LV_COLUMN lvColumn;

    memset(&lvColumn, 0, sizeof(lvColumn));
    lvColumn.mask = LVCF_FMT;

    m_MyListCtrl.GetColumn(0, &lvColumn);

    if((m_gListColumn[0].fmt & LVCFMT_RIGHT) == LVCFMT_RIGHT)
    lvColumn.fmt |= LVCFMT_RIGHT;
    else if(m_gListColumn[0].fmt & LVCFMT_CENTER) == LVCFMT_CENTER)
    lvColumn.fmt |= LVCFMT_CENTER;

    m_MyListCtrl.SetColumn(0, &lvColumn);





  3. #3
    Join Date
    May 1999
    Location
    United Kingdom
    Posts
    136

    Re: Right aligning first column in CListCtrl

    Thank you very much. Works wonderfully.

    :-)


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