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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Autocomplete Combo box questions.

Thread ID:

Created:

Updated:

Platform:

Replies:

122108 Feb 17,2016 03:55 PM UTC Nov 10,2016 06:23 AM UTC WinForms 5
loading
Tags: ComboBoxAutoComplete
Michael Toatley
Asked On February 17, 2016 03:55 PM UTC

I am creating an autocomplete combo box dynamically and adding it to a group control.
I am resizing the combo box based on the width of the selected text.  I want the dropdown width
the be the size of the largest string in the list.  The Dropdown width does not change when I set it
also I want to be able to restrict input to whats in the list when I set the allownew text to false it seems to disable my
autocompled functionality.



        private void btnAdd_Click(object sender, EventArgs e)
        {
            //TextBox txtSeg = new TextBox();
            //txtSeg.Text = cboSegment.Text;
            //AutoSizeTextBox(txtSeg);

//            txtSeg.Location = new Point(mYlocation, 30);
  //          mYlocation += txtSeg.Width + 10;

    //        this.Controls.Add(txtSeg);

            ComboBoxAutoComplete mCboSegment = new ComboBoxAutoComplete();
            List<String> mNewList = mSegmentList.ToList<String>();
            mCboSegment.DataSource = mNewList;

            mCboSegment.AutoCompleteCustomSource.AddRange(mSegmentList.ToArray<String>());
            //mCboSegment.AutoCompleteCustomSource.AddRange({ "One","two","three"});
            mCboSegment.AutoCompleteSource = AutoCompleteSource.CustomSource;
            mCboSegment.Location = new Point(mYlocation, 20);
            mCboSegment.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            mCboSegment.SelectedItem = 1;
            mCboSegment.SelectedValueChanged += new EventHandler(MCboSegment_SelectedValueChanged);
            mCboSegment.Tag = cboNum;
            mCboSegment.DropDownWidth = 600;
            mCboSegment.AllowNewText = false;
            cboNum++;
            mYlocation += mCboSegment.Width + 10;
            //this.Controls.Add(mCboSegment);
           
            grpCombo.Controls.Add(mCboSegment);
        }

Attachment: WindowsFormsApplication4_d919371f.zip

Senthil Kumaran Rajan [Syncfusion]
Replied On February 18, 2016 10:17 PM UTC

Hi Michael,

Thank you for contacting Syncfusion support.

The Width of the dropdown can be customized by the property named Preferred Width of the AutoCompleteControl in ComboBoxAutoComplete. Please make use of the below code example.

Code Example[C#]:

//To customize width of the AutoCompleteControl
mCboSegment.AutoCompleteControl.PreferredWidth = 250;


We have modified the sample based on the reported requirement and it can be downloaded from the below location.

Sample : http://www.syncfusion.com/downloads/support/forum/122108/ze/ComboBoxAutoComplete1303024503

Could you check with the above solution and let us know whether the provided solution is helpful? If not please provide some additional details about the reported requirement, it will be helpful for us to analyze and provide you a prompt solution as early as possible.

Regards,
Senthil

Rasika
Replied On November 8, 2016 07:02 AM UTC

this solution doesn't set the preferedwidth of combobx dropdown. can you give any other solution to set autocomplete dropdown width of combobox.
thanks.

Vinothini [Syncfusion]
Replied On November 9, 2016 06:28 AM UTC

Hi Rasika,   
   
Thank you for your update.   
   
As mentioned earlier, the width of the dropdown can be customized using PreferredWidth property. Please refer the below image and in that the width of the dropdown is set to 600 using the PreferredWidth property.   
   
 
Could you please check whether the PreferedWidth is set properly in your application? Or could you please give more details regarding your requirement?   
   
Regards,   
Vinothini   


Rasika
Replied On November 9, 2016 07:22 AM UTC

the version i worked on is 10.4.0.53.
can you provide the above solution in vs2010 version.
thanks.


Vinothini [Syncfusion]
Replied On November 10, 2016 06:23 AM UTC

Hi Rasika, 
 
Thank for your update. 
 
We have provided the sample in VS2010 and PreferredWidth property works as expected in the version 10.4.0.53. Please download the sample from the following location. 
 
 
Regards, 
Vinothini 


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

;