title: C# Set ListBox width so that longest item fits
body: <p>I would like to set my ListBox.Width property so that it is no wider nor narrower than needed, in order to display the items in it. There is a margin of a few pixels between the left of the ListBox and the start of the text - I would like there to be a similar margin on the right. (i.e. there shouldn't be a large gap, and the letters shouldn't be touching the right edge).</p>
  
  <p>Given that I'm not sure how many pixels a given string will be, I'm not sure how to calculate this width.</p>