Thread: Number of columns in ListControl

  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,981
    Use code tags when posting code.

    gg

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    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, 08:57 PM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM