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: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.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; } } }
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.




Reply With Quote