title: How to adjust width of a column to the width of the longest string in CListCtrl?
body: <p>I am trying:</p>
  
  <pre><code>tstring subItemText;
      CDC* pDc = GetListCtrl().GetDC(); 
      for (int row = GetItemCount() - 1; row &gt;= 0; --row) 
      {
        subItemText = _T("");
        for (int col = 0; col &lt; NumCol; ++col)  
        {
          subItemText = this-&gt;GetSubItemString( GetItemData(row), col);
          CSize sz; 
          // get length of the string in logical units, by default 1 unit == 1 pixel, type of font is accounted
          sz = pDc-&gt;GetOutputTextExtent(subItemText.c_str());
          if (static_cast&lt;int&gt;(sz.cx) &gt; ColWidth[col])
            ColWidth[col] = sz.cx; 
        }
      } 
      GetListCtrl().ReleaseDC (pDc);
      for (int col = 0; col &lt; NumCol; ++col) 
      {
        SetColumnWidth(col, ColWidth[col]);
      }
  </code></pre>
  
  <p>As result width of the column is on 20/30% larger than one of the largest string in that column.
  I want that width of column will be equal to width of string with max length.</p>
  
  <p>Thanks in advance!</p>