My project has two forms:
Form A - is an unbound listview which displays records from DataSet DS.
Form B - Contains Textbox input fields which will be used to update and add records to DS and then display them in listview on form A when form B is closed.
User presses command buttons on Form A to display Form B and add/edit records:
cmdAddButton to add new records
cmdEditButton to edit and update record.
My question is: Can I bind the DS to the Listview on Form A and then bind the Textbox Fields on Form B to the data set used in Listview on Form A. Also how do I display the added/edited items to the Listview on Form A when Form B is closed.
Presently I use a TableAdapter.FillBy to update table in dataset and a bindingsource bound to navigationbar to traverse through the Listview. My listview is unbound and I use the same binding source to load the listview in a separate subroutine.
I'm presently passing the listview to Form B as a new public shared control and then after form B is closed copying it back to the listyview on Form A. To update the underlying tables of ther data set on Form A I'm using Add or Update SQL in Form B. I would like to just add and update using the Dataset/Bndingsource and Table adapter. Please help with any suggestions
I have included some minor source code to demonstrate that I have coded all this in my solution (it has taken me 2 days), but I know that there is a much better way to do this. I'm a VB4,5,6 programmer and I have tried to use what Visual Studio 2008 offers but I have a very difficult time. I'm just so used to plain coding SQL statement and sending them to server and using unbound controls. Can someone help here. I'm very greatful for any suggestions.
Here is how I pass the listview from Form A to FormB update it and pass it back.
Private dim frmLV as listview
public dim sharedLV as New listview
'Get shared_LV to be the same as the Form A Listview
shared_LV = Me.frmA_LV
Dim frm as new FormB
If viewIndex = VIEW_SINGLE Then
frm.WindowState = FormWindowState.Normal
If Contains(userForm) Then Exit Sub
frm.MdiParent = Me
frm.WindowState = FormWindowState.Maximized
'To shows changes made to shared_LV in FormB input/update form.
Me.frmA_LV = shared_LV
'Now to get the DataSet to reflect new or updated info
Me.TradeHistoryTableAdapter.FillByDate(Me.AlpheusDataSet.tradeHistory, showHistory, fromDate, toDate)