1

I fear that there's an obvious answer to this staring me in the face but I can't figure it out...

Basically, I'm making a program to store details for different people. I was planning to create an XML file for each member, and display them in a DataGridView when the form containing it is loaded. The details will be collected through text boxes on an "Add Member" form.

What I would like to know is: How can I create XML files in code once the information is submitted, and how would I go about showing the details in a DataGridView?

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
  • As for creating the `xml`, I'll suggest you to look into the [`XmlSerializer`](https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer(v=vs.110).aspx) or this : http://stackoverflow.com/questions/11089275/serializing-objects-to-xml-in-c-sharp. And for the `DataGridView`, take a look to http://stackoverflow.com/questions/6092463/how-can-i-manually-add-data-to-a-datagridview – Xiaoy312 Apr 29 '16 at 17:26
  • XmlSerializer is your most obvious option here :) – ManoDestra Apr 29 '16 at 17:28
  • The easiest method is to use a DataTable. You can create a datatable and then display in datagridview in one instruction datagridview1.DataSource = dt. The DataTable class has methods DataTable.ReaxXml() and DataTableWriteXml() which will read and save results. An XmlSerializer is much more complicated to use so why use it when the is a very easy method. – jdweng Apr 29 '16 at 19:57

0 Answers0