wxListCtrl: Minimum size of a Coloumn on MSW.

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply
Experienced Solver
Experienced Solver
Posts: 58
Joined: Wed May 11, 2005 7:45 am

wxListCtrl: Minimum size of a Coloumn on MSW.

Post by Tom82 » Mon Sep 19, 2005 11:09 am

hi there,
i've got a problem today where i think many people noticed that problem too.

i have to view information in a wxListCtrl,
the Size of the Coloums should be as least as possible, but it should show all data. (all data means the Header and all Rows,

on MSW wxWidgets are supporting wxLIST_AUTOSIZE and wxLIST_AUTOSIZE_USEHEADER.

i made a workaround using this 2 features.

but it works only on MSW because wxLIST_AUTOSIZE_USEHEADER works just under MSW correct.

Code: Select all

    //from the first, to the last
    int i;
    for( i = 0; i <= yourLastColoumn; i++)
        int minSize = 0;
        m_pListCtrl->SetColumnWidth( i, wxLIST_AUTOSIZE );
        minSize = m_pListCtrl->GetColumnWidth( i );

        m_pListCtrl->SetColumnWidth( i, wxLIST_AUTOSIZE_USEHEADER );

        if (m_pListCtrl->GetColumnWidth(i) < minSize )
            m_pListCtrl->SetColumnWidth( i, minSize );

Developing for and with WinXp
wxWidgets 2.6.1
+ Jorg's wxTreeMultiCtrl
with VC++ 2003

Post Reply