Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i want to change Autocomplete in combo box when i type for example "zar",Autocomplete show me this list :

zar
raezarye
zarbaf
bafzar
zarif

in default Autocomplete in combo box show this list :

zar
zarbaf
zarif

but i don't want it , i write this code in key press but not work :

C#
private void frmProjects_Load(object sender, EventArgs e)
        {
var ListMohandesin = (from item in _db.UserProfiles
                                      orderby item.Family
                                      select new
                                      {
                                          DisplayMember = item.Name + " " + item.Family,
                                          ValueMember = item.UserId
                                      }).ToList();

                mcmbTMemary.DataSource = ListMohandesin;
                mcmbTMemary.DisplayMember = "DisplayMember";
                mcmbTMemary.ValueMember = "ValueMember";
                mcmbTMemary.SelectedIndex = -1;
                mcmbTMemary.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                mcmbTMemary.AutoCompleteSource = AutoCompleteSource.CustomSource;

}
 private void mcmbTMemary_KeyPress(object sender, KeyPressEventArgs e)
        {
            
                     
           mcmbTMemary.AutoCompleteCustomSource.OfType<string>().Where(a => a.ToLower().Contains(mcmbTMemary.Text.ToLower())).Any();
        }


please help me
tanks
Posted
Comments
BillWoodruff 29-Nov-14 5:45am    
I don't think you can modify auto-complete behavior in the MS Controls that support it to do this; I believe you'll have to write your own custom Control.
Maciej Los 30-Nov-14 15:48pm    
Please, debug the program and check what returns: mcmbTMemary.Text.ToLower() and remove Any()
mcmbTMemary.AutoCompleteCustomSource.Where(a => a.ToLower().Contains(mcmbTMemary.Text.ToLower()))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900