Click here to Skip to main content
15,614,421 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//for save to file
if (dlgSave.ShowDialog() == DialogResult.OK)

                //create the new file using the name of save dialog box
                FileStream fleProduction = new FileStream(dlgSave.FileName, FileMode.Create, FileAccess.Write, FileShare.Write);
                BinaryWriter bnrProduction = new BinaryWriter(fleProduction);

                //write each value in the file

//for load file
private void openToolStripMenuItem_Click(object sender, EventArgs e)
            if (dlgOpen.ShowDialog() == DialogResult.OK)
                FileStream fleProduction = new FileStream(this.dlgOpen.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                BinaryReader bnrProduction = new BinaryReader(fleProduction);

                textBox1.Text = bnrProduction.ReadString();
                label1.Text = bnrProduction.ReadString();

iam not unable to write the code for datagridview cell values like textboxes and labels.
i want to load and save to file for datagridview cell values.
datagridview have 5columns and 6 rows

anybody write code for datagridview cell values for save file and load file for retrive data from file.


1 solution


To fill a Datagrid you need to connect it with any Dataset or Datatable.

To load or save data from Gridview its easy to save the file in to XML or JSON format.

You can also use Dataset to export directly to XML format.

You can travel through the Gridview to make a custom datatable or dataset..

if you don't need to create a datatable or data set, then travel through each rows in the grid and then convert in to Datarow and then do what ever you need to do with it...

Share this answer
cadsolution 3-Nov-14 4:12am    
its,ok,but does it not possible without any dataset or datatable.
plz any idea of code letme urgently

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900