Number of columns in ListControl

This is a discussion on Number of columns in ListControl within the Windows Programming forums, part of the Platform Specific Boards category; Hi, What is the proper method to use way to set the number of columns in a list control. I ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Question Number of columns in ListControl

    Hi,

    What is the proper method to use way to set the number of columns in a list control. I inserted two columns and would like them to be the same width in the list control.


    This is what I have so far. Obviously I want to find the width of the list control and divide it by the number of columns.

    void CBirthView::OnInitialUpdate()
    {
    CFormView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();

    CString FirstName = "First Name";
    CString LastName = "Last Name";


    m_lcBirth.InsertColumn
    ( 0,FirstName,LVCFMT_CENTER,100 ,-1);
    m_lcBirth.InsertColumn
    (1,LastName,LVCFMT_CENTER, 100,-1);

    }

    MPSoutine

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648
    Use code tags when posting code.

    gg

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648
    To get the width of the list control's client area:
    Code:
    CRect r;
    m_lcBirth.GetClientRect(r);
    int listWidth = r.Width();
    gg

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    17
    Hi gg,

    Thanks for the help. I tried using a RECT instead of CRect. Your suggestion is sure easier.

    MPSoutine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help getting program print out the digit in words
    By cosmiccomputing in forum C Programming
    Replies: 26
    Last Post: 04-24-2008, 08:28 AM
  2. Need help with this compiler error
    By Evangeline in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 09:27 AM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  4. Finding a number within a number
    By jeev2005 in forum C Programming
    Replies: 2
    Last Post: 01-10-2006, 07:57 PM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM

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