I often have to fill the DataGridView columns about the following contents:
B b b b b p p b b
I do this:
for (int i = 0; i & lt; 5; i ++)
this.dgv [i, 0] .value = "b";
for (int i = 5; i & lt; 7; i ++)
this.dgv [i, 0] .value = "P";
for (int i = 7; i & lt; 9; i ++)
this.dgv [i, 0] .value = "b";
Maybe there is a way easier? For example, it is possible to somehow create an array (string [] record = {"b", "b", "b", "b", "b", "p", "p", "b", "B"};
) and with it to fill the columns?
Answer 1, Authority 100%
Speech about Windows Forms?
If the number of columns is known and constantly, but create them in the DataGridView editor, then combine data into one array and insert this.datagridview.rows.add (Array) .
this.datagridview1.rows.clear ();
Foreach (Var Array In Arrays)
{
this.datagridview1.rows.add (array);
}