Changing Cells content in a DataGridView using for

  • Thread starter Thread starter F.oliveirarocha
  • Start date Start date
F

F.oliveirarocha

Guest
Hi folks good afeternoon, I need a help form the specialists

I'm have a DataGridview in a Windows Form application thas is only for consult (it shows a list of invoices non paid)

I would like to change the content of the Status_cod that is in column "6" for the description using for and an if when the forms load, and I don't know how many lines the DataGridview would be.

Can someone help me with that please?

Here follows the code.

private void BaseTitulosaPagar_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dGVNumeroParcelasPagar.Numero_Parcelas_a_Pagar' table. You can move, or remove it, as needed.
this.numero_Parcelas_a_PagarTableAdapter.Fill(this.dGVNumeroParcelasPagar.Numero_Parcelas_a_Pagar);
txt_TotalGeral.Text = numero_Parcelas_a_PagarDataGridView.Rows.Cast<DataGridViewRow>().Sum(i => Convert.ToDecimal(i.Cells[Valor_Parcela.Name].Value ?? 0)).ToString("N2");
btn_fechar.Focus();

// Changing the value of Column 6 for the descriptions of the table Status_Invoice
try
{
for (int y = 0; y < numero_Parcelas_a_PagarDataGridView.RowCount - 1; y++)
{

if (numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells[6].Value.ToString() == "1")
{
numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells[6].Value = "Em Aberto";

}
else if (numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells[6].Value.ToString() == "2")
{
numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells[6].Value = "Quitado";
}

else if (numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells[6].Value.ToString() == "3")
{
numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells[6].Value = "Saldo Pendente";
}
}
}
catch (Exception Ex)
{
MessageBox.Show("Erro ao fazer a Substituição do Status do Título! " + Ex.Message);
}
}

I appologize for wrinting the code in Portuguese, because when I started I did not kwow that I would use this forum in English.

Thanks for your help.

Continue reading...
 
Back
Top