We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ComboBoxAdv and dropdownwidth

Thread ID:

Created:

Updated:

Platform:

Replies:

40295 Jan 31,2006 07:49 AM UTC Feb 2,2006 05:23 AM UTC WinForms 3
loading
Tags: Tools
Christian Rattat
Asked On January 31, 2006 07:49 AM UTC

Hi, is there a possibility to automatically set the width of the drop down area (DropDownWidth property) in comboboxadv depending on the content of the drop down? Thanks in advance, Christian

Christian Rattat
Replied On February 1, 2006 09:33 AM UTC

I just forgot this: We use SF Suite 3.0.1.0 (we plan to update to 4.1 soon). Thanks, Christian >Hi, > >is there a possibility to automatically set the width of the drop down area (DropDownWidth property) in comboboxadv depending on the content of the drop down? > >Thanks in advance, >Christian

Anupama Roy [Syncfusion]
Replied On February 1, 2006 10:55 AM UTC

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

Christian Rattat
Replied On February 2, 2006 05:23 AM UTC

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;