2 つのリストと 1 つのリスト ボックスがあります。リストはそれぞれ独自のクラスであり、リスト ボックスは Form1 にあります。各リストは、ピックアップ リストの場合は FrmPickups、リストの場合は FrmVisits というそれぞれの名前を持つ GUI によって追加されます。
私の質問は、データをリストに追加するときに、プロジェクトの起動時に再ロードされるようにデータベースに保存する方法と、起動時にリスト ボックスにロードする方法です。
一部のコードは次のとおりです。
データは次のようにリストに追加されます。
theVisit.name = txtName.Text;
theVisit.address = txtAddress.Text;
theVisit.arrival = DateTime.Parse(txtArrival.Text);
theVisit.Lat = Double.Parse(txtLat.Text);
theVisit.Lon1 = Double.Parse(txtLong.Text);
theVisit.type = "Visit";
ListBox の内容は次のように追加されます
/*
* Update the list on this form the reflect the visits in the list
*/
lstVisits.Items.Clear();
//Clear all the existing visits from the list
List<String> listOfVis = theList.listVisits();
//Get a list of strings to display in the list box
List<String> listOfpic = thePickup.listPickups();
//Get a list of strings to display in the list box
lstVisits.Items.AddRange(listOfVis.ToArray());
//Add the strings to the listBox. Note to add a list of strings in one go we have to
//use AddRange and we have to use the ToArray() method of the list that we are adding
lstVisits.Items.AddRange(listOfpic.ToArray());
//Add the strings to the listBox. Note to add a list of strings in one go we have to
//use AddRange and we have to use the ToArray() method of the list that we are adding