I'm developing a Tetris game in Windows Forms, I have programmed the movements of all the pieces, I now have to delete the lines that are painted completely.
To remove a line use the code:
dgvTetris.Rows.RemoveAt(27);
As soon as I remove a line, my program should automatically add a line at the beginning, which I can not do.
Follow the initial code for my Tetris:
private void FrmPrincipalTetris_Load(object sender, EventArgs e)
{
DataTable DT = new DataTable();
DT.Columns.AddRange(new[]
{
new DataColumn("0"), new DataColumn("1"), new DataColumn("2"), new DataColumn("3"), new DataColumn("4"), new DataColumn("5"), new DataColumn("6"), new DataColumn("7"), new DataColumn("8"), new DataColumn("9")
});
string[] Espaco = { "", "", "", "", "", "", "", "", "", "" };
for(int i = 0;i<=27;i++)
{
DT.Rows.Add(Espaco);
}
dgvTetris.DataSource = DT; // adiciona a matriz no dataGrid
//dgvTetris.Refresh();
for(int i=0;i<28;i++)// pinta as celulas de preto
{
for(int j=0;j<10;j++)
{
dgvTetris.Rows[i].Cells[j].Style.BackColor = Color.Black;
}
}
//dgvTetris.Rows.RemoveAt(27);// remove linha
//DT.Rows.Add(Espaco);
//DT.Rows.Add(Espaco);
//dgvTetris.DataSource = DT;
//dgvTetris.Rows.RemoveAt(27);
///dgvTetris.Refresh();
// dgvTetris.Rows[27].Delete();
//dgvTetris.Rows.Remove(dgvTetris.Rows[26]);
ID_Rotacao = 0;
}
If someone can help me, all that's missing is for me to finish my project.
Right now, Thank you.