Hi,
this works for me!
Thanks,
Christian
>
>Hi Christian,
>
>We cannot set the DropDownWidth automatically depending on the content of the dropDown.However,you can iterate through each added item and store the longest item''s length and measure the specified string that is drawn with specified font.Then you can assign this new width to the DropDownWidth property as illustrated below.
>
>Graphics g = this.comboBoxAdv1.CreateGraphics();
>
>this.comboBoxAdv1.DropDownWidth =longest.Length ;
>int offset = Convert.ToInt32(Math.Ceiling(g.MeasureString(" ",this.comboBoxAdv1.Font).Width));
>
>int newwidth = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(g.MeasureString(longest, this.comboBoxAdv1.Font).Width ))) + offset;
>
>this.comboBoxAdv1.DropDownWidth =newwidth;
>
>Please take a look at the sample attached.
>
>Regards,
>
>Anu.
>
>
trial_combo.zip