m_listctrl.SetColumnWidth( 0, LVSCW_AUTOSIZE );
The following was contributed by Roger Onslow.
(continued)
Here is a routine to auto-size columns. This routine allows for a minimum
column width (so columns don't disappear, or get too small for inplace
editing) and fits to the larger of the column heading and the actual cell
values.
Declare the following functions:
void AutoSizeColumns(int col = -1);
int GetColumnCount() const;
And here they are:
#define MINCOLWIDTH 10
int CMyListCtrl::GetColumnCount() const {
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);