This is a migrated thread and some comments may be shown as answers.

RadComboBoxElement

3 Answers 162 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Csaba Szolomajer
Top achievements
Rank 1
Csaba Szolomajer asked on 27 Apr 2011, 01:25 PM
Hi,

We would like to use telerik winform controls. So we start to test demo version.
We have a strange issue about the RadComboBoxElement placed on radribbonbar.

When I use the autocompletemod with SuggestAppend option at the first bind something happen with the popup list. (image attached wrong.png). When I click the arrow of the texbox part of the combobox,  the popup hide, after a click again the popup part shows correctly. (image attached good.png)

We use this event:

  
private void comboboxSearchAddress_TextChanged(object sender, EventArgs e)
        {
            if (comboboxSearchAddress.Text.Length > 2)
            {
  
                List<AddressPointType>
                    liAddrs = AddressPoint.SearchAddress(comboboxSearchAddress.Text);
  
                string s = comboboxSearchAddress.Text;
                 comboboxSearchAddress.Text = "";
                 comboboxSearchAddress.Items.Clear();
                for (int i = 0; i < liAddrs.Count; i++)
                {
                     
                    comboboxSearchAddress.Items.Add(new RadComboBoxItem(liAddrs[i].Caption,liAddrs[i]));
  
                }
                comboboxSearchAddress.Text = s;
                comboboxSearchAddress.Select(comboboxSearchAddress.Text.Length, 0);
                
            }
        }



Any Idea appreciate.
Thanks.
Csaba

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 May 2011, 10:36 AM
Hi Csaba,

Thank you for writing.

The code that you have sent will throw StackOverflowException, since in the TextChanged event you are rebinding the combo box and in the end your are setting back the text of the combo box, which will trigger the event again and again.

In order to use the auto complete functionality of the combo box, just set its AutoCompleteMode property to the desired mode. Here is an example of this:
public Form1()
{
    InitializeComponent();
 
    List<MyObject> towns = new List<MyObject>
        {
            new MyObject("Sofia", 1000),
            new MyObject("London", 2222),
            new MyObject("Munich", 3333),
            new MyObject("Los Angeles", 4444),
            new MyObject("Boston", 5555)
        };
 
    for (int i = 0; i < towns.Count; i++)
    {
        radComboBoxElement1.Items.Add(new RadComboBoxItem(towns[i].town, towns[i].zipCode));
    }
 
    radComboBoxElement1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
}
 
class MyObject
{
    public string town { get; set; }
    public int zipCode { get; set; }
 
    public MyObject(string town, int zipCode)
    {
        this.town = town;
        this.zipCode = zipCode;
    }
}

More information about the auto complete functionality can be found in this help article.

If this is not your case and your are trying to achieve something different, please write back with the exact details on your scenario. 

I am looking forward to your reply.

Best wishes,
Stefan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Csaba Szolomajer
Top achievements
Rank 1
answered on 11 May 2011, 10:23 AM
Hi,
Thanks for your reply.

So I would like to achieve this working method:

Start to type a city name. After 3 character typing (Bud) , I try to bind the auto complete list with city names like typed chars (Budapest, Budakeszi, Budaőrs). After select one from the auto complete list, I type the street name (Budapest H).  The suggested list (Budapest Hollos street, Budapest Hall street, Budapest Hamburger street .....) After that I would like to choose one exact address from the auto complete list. So U see I would like to change the object list continuously behind the auto complete data source.

Thanks
0
Stefan
Telerik team
answered on 16 May 2011, 04:51 PM
Hello Csaba,

Thank you for writing back.

If I understand correctly your scenario you want to bind the combo box to a source with towns, select a town and after that in the same combo you want to change its data source to a source with streets, select a street and after the street is selected to bind ones again the combo to a source with predefined exact addresses and choose the address. However, I am not sure regarding the selected values. What should happen with the selected town, city or address value? Where are you going to store them? Please, could you elaborate a bit more and describe the exact behavior that you want to achieve. 

I will be glad to help further and I am looking forward to your reply.
 
Greetings,
Stefan
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
DropDownList
Asked by
Csaba Szolomajer
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Csaba Szolomajer
Top achievements
Rank 1
Share this question
or