My form has 6 dataGridViews in different tabs of a tab Control, the user is able to enter values and change the cell backcolor, with a save button, the values for each dataGridView are saved into a text file, same with the backcolor of the cells in each dataGridView. When the user re-opens the form, all the last settings(style and values) are loaded again to the 6 dataGridViews; The problem is that when the user re-opens the form, the dataGridViews freeze and I don't find a way to fix that. Can someone help me?
My loading data and style code:
foreach (string s in File.ReadAllLines(stylePath))
{
string[] items = s.Split(';');
if (items.Length == 3)
{
dataGridView1.Rows[Convert.ToInt32(items[0])]
.Cells[Convert.ToInt32(items[1])]
.Style.BackColor = Color.FromName(Convert.ToString(items[2]));
}
}
StreamReader sr = new StreamReader(valuePath);
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
cell.Value = sr.ReadLine();
}
}
sr.Close();
Here is how it looks when re-opening the form: