Anyone here good with dataGridViews? Everytime i save the data in adds an empty row and since im saving everytime Form1_FormClosing is called it looks like this:
which is very annoying
The code I use to save is:
string file = Dir + "filename.bin";
using (BinaryWriter bw = new BinaryWriter(File.Open(file, FileMode.Create)))
{
bw.Write(dataGridView2.Columns.Count);
bw.Write(dataGridView2.Rows.Count);
foreach (DataGridViewRow dgvR in dataGridView2.Rows)
{
for (int j = 0; j < dataGridView2.Columns.Count; ++j)
{
object val = dgvR.Cells[j].Value;
if (val == null)
{
bw.Write(false);
bw.Write(false);
}
else
{
bw.Write(true);
bw.Write(val.ToString());
}
}
}
}