Login to ZARP
|
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());
}
}
}
} |
|
ex Surf & Bhop Server Owner
Login or register to post a reply.
|
Disable AllowUserToAddRows. I think you're writing the default empty row to the file as well as the data you've added yourself. That's what it looks like from the information you've given anyways. If it doesn't work, then feel free to add me on Steam.
|
|
Last Edit: 4 years 7 months ago by bunnyslippers69.
Login or register to post a reply.
The following user(s) said Thank You: Killa Kappa, Knuthulhu
|
Bunnyslippers69 wrote:
Disable AllowUserToAddRows. I think you're writing the default empty row to the file as well as the data you've added yourself. That's what it looks like from the information you've given anyways. If it doesn't work, then feel free to add me on Steam. This worked, Thank you. Post can now be locked |
|
ex Surf & Bhop Server Owner
Login or register to post a reply.
|