Hi all.
I've been searching for this for some time but still i'm not able to update my comboboxes. The scenarios is as following: i have a combobox with items from a sql database. I have an add and remove button for adding and removing values from the database table where that combobox is receiving the values. The thing is when i add or remove, it adds or removes from the database but the combobox will not reproduce those changes in runtime. How can i do that? I've tryied to inicialize the combobox all over again the same way it does when the application first starts but all i get is or an empty combobox or the items remain the same.
I really would like some help in this matter.
Thank you all!!
Loading
Nuno TeodoroPosted Apr 9, 2009, 9:40 AM
System.Windows.Forms.BindingSource novoBind = new BindingSource();
GEP.DS_Averiguadores dS_Averiguadores = new GEP.DS_Averiguadores();
GEP.DS_AveriguadoresTableAdapters.AveriguadoresTableAdapter averiguadoresTableAdapter = new GEP.DS_AveriguadoresTableAdapters.AveriguadoresTableAdapter();
averiguadoresTableAdapter.ClearBeforeFill = true;
dS_Averiguadores.DataSetName = "DS_Averiguadores";
dS_Averiguadores.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
novoBind.DataMember = "Averiguadores";
novoBind.DataSource = dS_Averiguadores;
comboBox1.DataSource = novoBind;
comboBox1.AccessibleName = "comboBox1";
comboBox1.AllowDrop = true;
comboBox1.Cursor = System.Windows.Forms.Cursors.Default;
comboBox1.DisplayMember = "Nome";
comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
comboBox1.FormattingEnabled = true;
comboBox1.Location = new System.Drawing.Point(121, 24);
comboBox1.Name = "comboBox1";
comboBox1.Size = new System.Drawing.Size(187, 21);
comboBox1.TabIndex = 2;
comboBox1.ValueMember = "Nome";
thank you!
Nuno TeodoroPosted Apr 9, 2009, 9:03 AM
DS_Averiguadores test= new DS_Averiguadores();
comboBox1.DataSource = teste;
Where DS_Averiguadores is the datasouce i'm using.
After that, what i obain in the combobox is this:
System.Data.DataViewManagerList|ter
Nuno TeodoroPosted Apr 9, 2009, 8:49 AM
I have the problem that, for accessing the combobox in the main interface i have to do it in the main interface code and i cant create a static method to be called by the input interface you see? This is because the combobox is created private and if i modifi it to be static like public static combobox; it automatically put's it in private again after some time!