Combo Boxes in Windows Forms (Data Binding)
-
A question concerning the behavior... Ex. I bind the data to a DataSet in the Form_Load() event. I have an event that is triggered when on the SelectedIndex_Changed event. On the load, the DataBind is causing the SelectedIndex event to fire which sort of makes sense. Is there flag or property I can set around the code block which binds the data to force it not to trigger that event.
-
A question concerning the behavior... Ex. I bind the data to a DataSet in the Form_Load() event. I have an event that is triggered when on the SelectedIndex_Changed event. On the load, the DataBind is causing the SelectedIndex event to fire which sort of makes sense. Is there flag or property I can set around the code block which binds the data to force it not to trigger that event.
There's no flag like this, I think. Create Your own - or - disconnect handler before DataBind and connect it after loading data Hi, AW
-
A question concerning the behavior... Ex. I bind the data to a DataSet in the Form_Load() event. I have an event that is triggered when on the SelectedIndex_Changed event. On the load, the DataBind is causing the SelectedIndex event to fire which sort of makes sense. Is there flag or property I can set around the code block which binds the data to force it not to trigger that event.
It is because.first u are seting the data source and then u might be setting the dispaly member and value member.... u can do like this
cmbClassId.DisplayMember = dataSet.Tables[Constants.CLASSES].Columns["ClassName"].ToString();
cmbClassId.ValueMember = dataSet.Tables[Constants.CLASSES].Columns["ClassID"].ToString();
cmbClassId.DataSource = dataSet.Tables[Constants.CLASSES];This will cause event to occure only once.
dipak