Why doesn’t my Datagrid add anything?

Asked

Viewed 40 times

1

public partial class TelaQuadroAdm : Form
{
    public TelaQuadroAdm()
    {           
        InitializeComponent();           
    } 

    private void TelaQuadroAdm_Load(object sender, EventArgs e)
    {
        Quadro q = new Quadro();
        List<Pais> l = new List<Pais>();
        l = q.obterQuadro();
            foreach (var pais in l)
            {
                object[] row = {
                    pais.posicao,
                    pais.sigla,
                    pais.nome,
                    pais.ouro,
                    pais.prata,
                    pais.bronze,
                    pais.total,                
                };

                dataGridQuadroAdm.Rows.Add(row);
            }
    }

    void BtnMaisClick(object sender, EventArgs e)
    {

        Hide();
        TelaAdicionarPais tela = new TelaAdicionarPais(dataGridQuadroAdm);

        tela.ShowDialog();
    }

    void BtnMenosClick(object sender, EventArgs e)
    {
        int linha = dataGridQuadroAdm.CurrentCell.RowIndex;

        string sigla = (string)dataGridQuadroAdm.Rows[linha].Cells[1].Value;    
        Quadro q = new Quadro();
        Hide();
        q.remover(sigla);
        TelaQuadroAdm tela = new TelaQuadroAdm();
        tela.ShowDialog();          
    }

    void BtnAlterarPaisClick(object sender, EventArgs e)
    {
        int linha = dataGridQuadroAdm.CurrentCell.RowIndex;

        string sigla = (string)dataGridQuadroAdm.Rows[linha].Cells[1].Value;
        Hide();
        TelaAlterarPais tela = new TelaAlterarPais(sigla);

        tela.ShowDialog();
    }

    void BtnGerenciarUsuarioClick(object sender, EventArgs e)
    {
        Hide();
        TelaGerenciarUsuario tela = new TelaGerenciarUsuario();

        tela.ShowDialog();
    }

    void BtnLogoutClick(object sender, EventArgs e)
    {
        Hide();
        TelaQuadroVisitante tela = new TelaQuadroVisitante();

        tela.ShowDialog();
    }

    void DataGridQuadroAdmCellContentClick(object sender, DataGridViewCellEventArgs e)
    {

    }
}

1 answer

2

Apparently by mistake, it seems that the InitializeComponent(); inside the form constructor public TelaQuadroAdm()

public TelaQuadroAdm()
{
   InitializeComponent();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.