473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Update Combobox Contents

Hi:
I have a combobox (in form 1) whose items are populated from a table. In
form 2 there is a data entry for the same table. How do I reflect the
changes to the combobox in form 1 as soon as the data entered in form 2 is
saved in the table? Thanks in advance.
Nov 16 '05 #1
2 3840
Hi,

One way to accomplish this is rebind the data in the combobox in an event
that fires upon completion of the data entry. This way the combobox will
reflect the changes of the data entered on your form.

I hope this helps.

Nov 16 '05 #2
First of all I write a class in a seperate file as this
using System;

using System.Windows.Forms

public class Watcher

{

private System.Windows.Forms.ComboBox combo;
public Watcher()

{

}

public Watcher(ref System.Windows.Forms.ComboBox cb)

{

this.combo = cb;

}
public void AddItem()

{

this.combo.Items.Add("SerhaD");

}

}

Both Form1 and Form 2 have an instance of this class. In The Form 1 it is a
private, Form2's is public member

//////In your Form1.comboBox fill function do

watcherForm1 = new Watcher(ref comboBox1);

//////while constructing Form2 Do this

Form2 f2 = new Form2();

f2.watcherForm2 = watcherForm1;

fe.ShowDialog();

/////// In the Form2 you may call AddItem function of Watcher Class

watcherForm2.AddItem(); //this adds SerhaD to the combo

////Turn to the Form1 and Look at the Combo and that's it

SerhaD is added to the Combo from Form2 !

Hope you get the idea ,



"A. Chiou" <A. Ch***@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
Hi:
I have a combobox (in form 1) whose items are populated from a table. In
form 2 there is a data entry for the same table. How do I reflect the
changes to the combobox in form 1 as soon as the data entered in form 2 is
saved in the table? Thanks in advance.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: noone | last post by:
I'm making a sales order database similar to Northwinds but with a slightly different form. The tables are the same. The 'Sales Orders' form has a 'Line Items' subform. I've added a 'Add Item'...
1
by: thomaz | last post by:
When i make an update in my database, the modifications are showing in all TEXTBOX but i can´t see the new values in a combobox text. If i close the form and open it again the new values will...
2
by: John Tyce | last post by:
When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items.Add(string) or ComboBox.Items.Insert(0,string); Either way, the new string does not show up in the...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
9
by: ukjock | last post by:
I am very new to the whole Visual Basic .net scene, and I am trying to get to grips with it... I thought I would try and learn a programming language, and I was advised on vb.net. I have already...
1
by: fiaolle | last post by:
Hi I have tried to update my combobox with no luck. I add records to the table, the combobox has as Datasource, but I don't know how to update the combobox. I have tried updata the oledbadapter...
5
by: njb35 | last post by:
Hi all I'm beginning my foray from VBA into VB 2005 Express, and enjoying some of the efficiencies it provides! I'm stuck with some dataset handling however that I _think_ can be automated but...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
0
by: XenReborn | last post by:
Ok this should be simple. I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.