I am writing a code to make sure that if the translate button is pressed a new row appears but all the row members except string text are visible..Now i have written the code but it only makes the button disappear and all the members are still visible.
This is the view after the button is pressed..
Now the button is invisible but all the other members are still visible.this is the code i have tried..
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
bool ce = false;
bool check = true;
Column_handling();
DataGridViewTextBoxCell c = new DataGridViewTextBoxCell();
if(!(dataGridView1.Rows[e.RowIndex].Selected))
{
dataGridView1.Rows[e.RowIndex].Selected = false;
if (e.ColumnIndex == 10)
{
if((Convert.ToInt16(this.dataGridView1.Rows[e.RowIndex].Cells[0].Value) == Convert.ToInt16(this.dataGridView1.Rows[e.RowIndex + 1].Cells[0].Value)) && (Convert.ToInt16(this.dataGridView1.Rows[e.RowIndex].Cells[1].Value) == Convert.ToInt16(this.dataGridView1.Rows[e.RowIndex + 1].Cells[1].Value)))
{
ce = true;
}
if(!ce)
{
DataRow dt = datarows.NewRow();
dt[0] = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
dt[1] = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
dt[2] = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
dt[3] = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
dt[4] = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
dt[5] = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
dt[6] = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
dt[7] = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();
dt[8] = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
dt[9] = this.dataGridView1.CurrentRow.Cells[9].Value.ToString();
datarows.Rows.InsertAt(dt, e.RowIndex + 1);
var row = this.dataGridView1.Rows[e.RowIndex + 1];
DataGridViewColumn column = dataGridView1.Columns[2];
DataGridViewCell cella = new DataGridViewTextBoxCell();
cella.Style.BackColor = Color.Wheat;
column.CellTemplate = cella;
var cell = new DataGridViewTextBoxCell();
cell.Value = string.Empty;
var cell1 = new DataGridViewTextBoxCell();
cell1.Value = string.Empty;
var cell2 = new DataGridViewTextBoxCell();
cell2.Value = string.Empty;
var cell3 = new DataGridViewTextBoxCell();
cell3.Value = string.Empty;
var cell4 = new DataGridViewTextBoxCell();
cell4.Value = string.Empty;
var cell5 = new DataGridViewTextBoxCell();
cell5.Value = string.Empty;
var cell6 = new DataGridViewTextBoxCell();
cell6.Value = string.Empty;
var cell7 = new DataGridViewTextBoxCell();
cell7.Value = string.Empty;
var cell8 = new DataGridViewTextBoxCell();
cell8.Value = string.Empty;
var cell9 = new DataGridViewTextBoxCell();
cell9.Value = string.Empty;
var cell10 = new DataGridViewTextBoxCell();
cell10.Value = string.Empty;
row.Cells[10] = cell;//the button column
row.Cells[0] = cell2;
row.Cells[1] = cell3;
row.Cells[3] = cell4;
row.Cells[4] = cell5;
row.Cells[5] = cell6;
row.Cells[6] = cell7;
row.Cells[7] = cell8;
row.Cells[8] = cell9;
row.Cells[9] = cell10;
cell.ReadOnly = true;
dataGridView1.ReadOnly = true;
dataGridView1.Refresh();
}
else if (!cao)
{
dataGridView1.Rows[e.RowIndex + 1].Visible = true;
var row = this.dataGridView1.Rows[e.RowIndex + 1];
var cell = new DataGridViewTextBoxCell();
cell.Value = string.Empty;
row.Cells[10] = cell;
cell.ReadOnly = true;
dataGridView1.Refresh();
cao = true;
}
else if (ce)
{
dataGridView1.Rows[e.RowIndex + 1].Visible = false;
var row = this.dataGridView1.Rows[e.RowIndex + 1];
var cell = new DataGridViewTextBoxCell();
cell.Value = string.Empty;
row.Cells[10] = cell;
cell.ReadOnly = true;
dataGridView1.Refresh();
cao= false;
}
}
}
}