I have a windows form app that connects to a database.
After data is inserted into the database, i need a way to refresh the form data so that it is available after the insert.
The form I have has a combo box that when a selection is made the appropriate data is dispslay on the rest of the form. Right now, after the insert, the new item in the combo box is not in the list, so I have to close the form and reload it.
Thanks in advance.
DAniel
Loading
Buster IrbyPosted Aug 24, 2007, 10:03 AM
The easy way is to bind your text boxes to your data source and then the refresh will happen automatically. For example:
textbox.DataBindings.Clear();
textbox.DataBindings.Add(
"text", tbl_UserInfo.ds, "tbl_UserInfo.Name" );Note: I use my own table data type, tbl_UserInfo, which contains a data source (ds) type.
The field in quotes "tbl_UserInfo.Name" must exactly match the table and field information in the database
All TextBoxes, ComboBoxes, and many other data types have a DataBindings property which will automatically update the information in that control when the binding context manager changes the currency pointer. This means it will update if you move to a different existing record as well as adding a new one.