Avatar of RichDu
RichDu
 asked on

c# combobox autocomplete behavior

Hi guys and girls,

I wrote an apps in c# and just found out that for some computer who need to stay in XP for compatibility reason (old soft), i have a different autocomplete behavior with combobox.

 wrote 351 and all my list starting with 351 appear like this

- What i want (and work perfectly on win7 and above)

351
351-A
3510
351C

- What i got with XP (SP3)

wrote 351 but as soon as i get the 1 i got this

351

Everyting in my list witch is not exacly 351 is not visible.

My combobox is autocompletemode = Suggest and autocompletesource = listitems. I also tried SuggestAppend and nothing change. If anyone have a clue i would appreciate !

Thank you
C#.NET ProgrammingProgramming

Avatar of undefined
Last Comment
RichDu

8/22/2022 - Mon
it_saige

Could you provide example code that recreates the issue?

-saige-
RichDu

ASKER
Hi it_saige,

I would like to but i dont know which code i can provide. The combobox is filled by a SQL resquest. The setting of my combobox is ajusted with the properties tab.

If i press manually to access the list, everything is there in both OS. If i wrote in the combobox, than a list is made with the Suggest setting. The only difference is the fact that the list is not complete with XP as is it with win7.

If there's more info i can provide please dont hesitate !

Thank you
it_saige

Let's start with how you fill your combobox.  You said it is filled by a SQL request.  Do you fill it directly from a datareader; e.g. -
while (reader.Read()) 
{
	combobox1.Items.Add(reader["SomeFieldName"].ToString());
}

Open in new window

Do you fill a list and set the list as a datasource for the combobox; e.g. -
List<SomeObject> objects = new List<SomeObject>()
while (reader.Read())
{
	objects.Add(new SomeObject() { SomeFieldName = reader["SomeFieldName"].ToString() });
}
combobox1.DataSource = objects;

Open in new window


This code would be important.  Also you mention settings adjusted by properties.  What are the settings you adjust and then verify that you do not make any changes to the properties of the control within other methods of your form, if you do, include those changes.

-saige-
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
RichDu

ASKER
there it is

try
            {
                SqlConnection read = Cts.Login.ConnectRead();

                SqlCommand mycom = read.CreateCommand();

                mycom.CommandText = "SELECT Selection " +
                     "FROM ItemsQuinc ORDER BY Selection ASC";

                SqlDataAdapter da = new SqlDataAdapter(mycom);

                DataSet dataSet = new DataSet();
                da.Fill(dataSet);

                itemComboBox.DataSource = dataSet.Tables[0];

                itemComboBox.DisplayMember = "Selection";

                read.Close();
                read.Dispose();

            }

            catch (SqlException ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return;
            }

Open in new window


The only oyher setting i've change is FormattingEnabled = true. All others setting ar by default.

Thank you !
ASKER CERTIFIED SOLUTION
it_saige

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
RichDu

ASKER
Hi saige,

It works perfectly !!!

i will have to understand why the properties setting wont work but the way you make it work well.

Thanks again for your time :)