ComboBox.PreferredSize

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?=

    ComboBox.PreferredSize

    Hi,
    In a C#.Net2.0 Winforms application I have some combo boxes. I ind these
    boxes to enum values and then call
    ComboBox.Size = ComboBox.Prefer redSize:
    But, the combo box is never wide enough to display long items! Isn't that
    what PreferredSize is uspposed to give? Am I missing something or is there
    another way to make sure that my comboboxes are wide enough to display all
    the text in them?

    Thanks!
    Ethan
  • Pavel Minaev

    #2
    Re: ComboBox.Prefer redSize

    On Aug 5, 10:52 pm, Ethan Strauss
    <EthanStra...@d iscussions.micr osoft.comwrote:
    Hi,
      In a C#.Net2.0 Winforms application I have some combo boxes. I ind these
    boxes to enum values and then call
    ComboBox.Size = ComboBox.Prefer redSize:
    But, the combo box is never wide enough to display long items! Isn't that
    what PreferredSize is uspposed to give?
    It is not. Control.Preferr edSize is about sizing of controls when they
    are layed out automatically (using TableLayoutPane l/FlowLayoutPanel ).
    Am I missing something or is there another way to make sure that my comboboxes are wide enough to display all
    the text in them?
    You can use ComboBox.DropDo wnWidth to make the width of the dropdown
    list larger to accomodate long strings; but there is no way that I
    know of to make it auto-sizing. If you really need it, you can use
    TextRenderer.Me asureText to measure width of all items, and update
    DropDownWidth according to the measurements.

    Thanks!
    Ethan

    Comment

    Working...