0

i want to ask how to permanently save user input data read in through different TextBoxes and only temporary saved in a DataGrid (Data get lost after closing the application).

I do not want to use SQL for this application. I just want to store the user input data constantly even if closing VS2017.
Is there a commando to make it possible?

Code As Requested:

namespace New_Adress_Book
{

public partial class MainWindow : Window
{

    public MainWindow()
    {
        InitializeComponent();
        dg.ItemsSource = personen;
    }

    List<Person> personen = new List<Person>();

    private void Button_Speichern(object sender, RoutedEventArgs e)
    {
        personen.Add(new Person(Vorname.Text, Nachname.Text, Strasse.Text, Hausnummer.Text, Ort.Text, TelNr.Text));
        dg.Items.Refresh();
    }
 }

    class Person
    {
        public Person (string vn, string nn, string str, string hnr, string ort, string telnr)
        {
            this.Vorname = vn;
            this.Nachname = nn;
            this.Strasse = str;
            this.Hausnummer = hnr;
            this.Ort = ort;
            this.Telefonnummer = telnr;
        }

    // Something seems to be missing here...

    public string Vorname
    {
        get;
        set;
    }
    public string Nachname
    {
        get;
        set;
    } ...

   }
}

Sorry for any grammatical mistakes you will find and sorry for any offense against the Forum rules. I am really new to this!

CSharper
  • 11
  • 3
  • All your (possible) mistakes are forgiven (and edited out), but the layout of your class `Person` still seems to be incoherent, because your inner class seems to have no closing tags. – zx485 Sep 19 '18 at 19:29
  • @zx485 Thank you! Yes there are some brackets missing. Thanks. – CSharper Sep 20 '18 at 08:06
  • Have you tried to store your `Person` Class into a xml File and load it/them when the application starts? (Additionally i recommend to give the Persons a UUID) – LittleBit Sep 20 '18 at 08:19
  • I would also write the details before closing in xml file and load it back on opening your application. – Lion King Sep 20 '18 at 08:32

0 Answers0