Re: Combobox autocomplete
Can we see this SelectedIndexChanged event handler?
Re: Combobox autocomplete
sure but really there is nothing to see :)
Code:
orderBindingSource.EndEdit();
Order o = orderBindingSource.Current as Order;
TList<Product> productList = productService.GetByCustomerID(o.CustomerID);
productBindingSource.DataSource = productService.GetByCustomerID(o.CustomerID);
foreach (OrderDetail orderDetail in o.OrderDetailCollection)
{
if ( productList.Count > 0 )
{
if ( productList.Find(ProductColumn.ID,orderDetail.ProductID) == null )
{
orderDetail.ProductID = productList[0].ID;
}
}
else
{
orderDetail.ProductID = 0;
}
}
Re: Combobox autocomplete
What's the DropDownStyle of this control: DropDown or DropDownList? Also, what are it's auto-complete properties set to?
Re: Combobox autocomplete
It's DropDown and the auto-complete is None.
Re: Combobox autocomplete
That makes no sense to me. How can typing into the ComboBox change the SelectedIndex anyway? There must be something in another event handler, like TextChanged or KeyPress, that is causing the issue.
Re: Combobox autocomplete
none at all, thats the only event that is implemented in the code for that control.
Re: Combobox autocomplete
I don't really see how that's possible. I just created a new WinForms app and added a ComboBox to the form. I then changed the form's code file to this:
C# Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
List<Order> orders = new List<Order>();
orders.Add(new Order(1, "alpha"));
orders.Add(new Order(2, "november"));
orders.Add(new Order(3, "tango"));
orders.Add(new Order(4, "tangle"));
this.bindingSource1.DataSource = orders;
this.comboBox1.DataSource = this.bindingSource1;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Console.WriteLine((this.bindingSource1.Current as Order).Name);
}
}
public class Order
{
private int _id;
private string _name;
public int ID
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public Order(int id, string name)
{
this._id = id;
this._name = name;
}
}
}
When I ran the project the Output window showed "alpha" as expected as the first item was selected. I then typed "t" and "a" and, as expected, there was no new output because entering characters into the box doesn't raise the SelectedIndexChanged event.
I suggest that you place a breakpoint on the first line of the event handler and then when it's hit take a look at the Call Stack window to see where it has come from. I just don't see how it could be caused merely by entering a letter in the box.
Re: Combobox autocomplete
i agree with you, i can do it fine in a new project (typing in letters and it filters down to the item in the dropdownlist)
ill see what i can find and post back
Re: Combobox autocomplete
Umm, maybe I am retarded, but shouldn't you have to click a Button to begin any database stuff?
if you had
tab
tabb
taabbitha
in a drop down the last thing you want is for the thing to start doing stuff when you havent made sure that is the item you want.
In other words, have them select the item then click a button to start all the work.
Re: Combobox autocomplete
Maybe it would be worth deleting this ComboBox and adding a new one. Something screwy is going on so that should hopefully get rid of that, then you can wire up the new one as you want.
Re: Combobox autocomplete
its just a project ive taken over and cant really change the "specs" of it. The designer is also screwed up so I'll give it a shot in terms of removing and re-adding the combobox programmatically in code behind/designer code.
Re: Combobox autocomplete
I feel your pain. Good luck.
Re: Combobox autocomplete
ok I tried re-doing the combobox but it made no difference (and I did not implement the SelectedIndexChanged event yet).
It still seems to think that everytime I press a letter (together in a sequence when typing a word) that each letter is the first input it ever recieved.
any further suggestions?
I tried this on a new project, just a simple project and binding the combobox to a datasource and it acted in the same way! it wont let you type to filter down to the name you want...but only accepts the first character as input and thats it.
Re: Combobox autocomplete
hang on, i think i got it!
of course, i remember now - its coming back to me. its been a year since i did this.
Set the AutoCompleteMode to "Suggust" and the AutoCompleteSource to "ListItems" for the combobox.....and it did it :)
unfortunately the selectedindexchanged event will fire when it is "autocompleting" which means im back to square one. So I guess maybe I need to add a button instead to load the record which is a downfall