In this I am creating a grid of 2 rows and 3 column.
For stopping automatic increment of rows ,you have to set dataGridView1.AllowUserToAddRows = false in the grid
property..
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 0;
for (int I = 1; I <= 3; I++)
{
dataGridView1.Columns.Add("DSRO" + I, "DSRO");
}
dataGridView1.RowCount = 2;
}
To open a file and saving the content in file I am using Visual Basic .
It involve following step:
1. goto Project then click Add Reference and then click Microsoft Visual Basic
2. you have to include the namespace using Microsoft.VisualBasic
3. you have to add another button and on the click of that button you create a text file ,reading the data from the grid and saving it on the text file.
private void button2_Click(object sender, EventArgs e)
{
FileSystem.FileOpen(1, @"C:\Users\yogesh\filename.txt", OpenMode.Output, OpenAccess.Write, OpenShare.Shared, 50);
float EXE[,]=new EXE[2,3];
for (int I = 0; I< 2; I++)
{
for (int J = 0; J < 3; J++)
{
EXE[J] = (float)(Convert.ToDouble(dataGridView1.Rows[I].Cells[J].Value));
}
}
for(int I=0;I<2;I++)
{
for (int J = 0; J < 3; J++)
{
FileSystem.Print(1, EXE[I,J]);
}
}
FileSystem.FileClose(1);