How to perform event with class instantiated in another method

1

I have a method that instantiates a "BandedGridView":

 private void popula_retContrato(string contrato)
    {
        Classes.Datatable.Datatable_cliContrato dat_contrato = new Classes.Datatable.Datatable_cliContrato();

        gridControl4.Visible = true;

        DataSet set = new DataSet();

        set = dat_contrato.contrato_set(contrato);

        gridControl4.DataSource = set.Tables["contratos"];
        gridControl4.ForceInitialize();

        GridBand tag = new GridBand() { Caption = "Sumário" };

        BandedGridView bandgridview4 = new BandedGridView(gridControl4);

        bandgridview4.Bands.Add(tag);

        gridControl4.LevelTree.Nodes.Add("relator", bandgridview4);

        bandgridview4.ViewCaption = "Relatórios";
        bandgridview4.PopulateColumns(set.Tables["relatorios"]);

        format_grid_contrato();
        format_subgrid_contrato(bandgridview4);
    }

I need to use this BandedGridView instance in an event:

private void click_datagridview4(object sender, EventArgs e)
    {
        id_etiqueta = Convert.ToInt32(bandgridview4.GetRowCellValue(bandgridview4.GetSelectedRows()[0], "Nº"));

        MessageBox.Show("valor id_etiqueta " + id_etiqueta);
    }

However when using the above code and generated error:

How could I accomplish this?

    
asked by anonymous 05.10.2016 / 16:10

1 answer

0

I was able to resolve it as follows:

private void click_datagridview4(object sender, EventArgs e)
    {
        BandedGridView bandgridview4 = (BandedGridView)sender;

        id_etiqueta = Convert.ToInt32(bandgridview4.GetRowCellValue(bandgridview4.GetSelectedRows()[0], "Nº"));
    }
    
05.10.2016 / 16:40