3

I have created one C# Windows form that have one DataGridView I can add or remove some row from this DatagridView, but now I wonder how can I save my changes, so every time I open my window I can see my added row.

P.S.: I must mentioned that I don't want use any databases, is there any solution?
Is it possible to do that with C# Application settings?

enter image description here

Am1rr3zA
  • 7,115
  • 18
  • 83
  • 125
  • 1
    you have to save somewhere else, if you are not storing in DB. may be you can store in File (CSV, xml) ??? – Ravi Gadag Jan 04 '12 at 11:39
  • some of them (like DACs and Reader are saved in Application setting) and some of them added by user directly (like Location) – Am1rr3zA Jan 04 '12 at 11:39

5 Answers5

5

Stick the contents into a DataSet (boo hiss) and serialize that to either a binary file or as XML.

Let's all laugh at the "cutting edge" label of this article:

http://msdn.microsoft.com/en-us/magazine/cc163911.aspx

It won't require a database, just a file.

If you go this route, you could then data bind your grid to this backing DataSet, this will make the process of populating the DataSet with the contents a lot easier.

Adam Houldsworth
  • 63,413
  • 11
  • 150
  • 187
1

Yes, you can save it using C# Application Settings, but you need to do some formatting. Hey buddy, even txtfile can be called as database.

John Woo
  • 258,903
  • 69
  • 498
  • 492
1

All these answers suggest the following:

Create a new class with methods that take your datagrid as a parameter and save it a particular way. One method for saving as CSV, one for XML, etc. Now you can play with with all this w/out breaking your original code during your learning process.

Then you can assess the various methods empirically and decide which is best for you.

radarbob
  • 4,964
  • 2
  • 23
  • 36
0

The best option I can see is to store this data into disk in XML format. It will also help you to read it back at later stage directly into dataset.

Maheep
  • 5,539
  • 3
  • 28
  • 47
0

i prefer you can save in xml or csv format to store the app settings, and later you can read through it :) .

Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83