Datagridview updating by child form

Asked

Viewed 183 times

1

I have a main form (form1) where I carry a datagridviwer and I need to do this: I have a second form (form2) deleting the selected line in datagridviwer (form1), I just need to do that when I delete the line from the datagridviwer with the button on form2, he closes the screen of form2 and back to the screen of form1 already updated, ie with the line deleted, how can I do this?

Follow my code that updates the datagridviwer;

{
    conm.Open();
    adap = new SqlDataAdapter(@"select 
                                        sa.Cod_Solicitacao,
                                        cli.Cliente,
                                        cli.Contato,
                                        sa.Solicitante,
                                        sa.Representante,
                                        sa.Area_Atuacao,
                                        sa.Tipo_Envio,
                                        sa.Separador,
                                        convert(varchar(10), cast(Data_Entrega as date), 103) as Finalizado,
                                        cli.Id_Cliente,
                                        sa.Id_Solicitacao
                                from tbl_SolicitacaoAmostra as sa
                                inner join tbl_Cliente as cli with(nolock) on cli.Id_Cliente = sa.Id_Cliente
                                inner join tbl_Produto as pro with(nolock) on pro.Id_Solicitacao = sa.Id_Solicitacao
                                where sa.Deletado is null and cli.Deletado is null and pro.Deletado is null
                                group by sa.Cod_Solicitacao, cli.Cliente, cli.Contato, sa.Solicitante, sa.Representante, sa.Separador, sa.Area_Atuacao, sa.Tipo_Envio, sa.Separador, sa.Data_Entrega, cli.Id_Cliente, sa.Id_Solicitacao", conm);
    ds = new DataSet();
    adap.Fill(ds, "Solicitacao");
    DGW_solictacao.DataSource = ds.Tables[0];
    conm.Close();
}
MessageBox.Show("Solicitação excluida com sucesso!!!");
this.Dispose();
  • But vc effectuates the deletion effectively in the table, because if yes, it is only vc Sar a this.Clouse(); and call the method that loads the data grid again I will do a new search with the deleted rows. Otherwise the question is unclear

  • Renan thank you very much. gave it right here was just what I needed. vlw.

  • That’s cool, so I’ll put it in answer.

1 answer

0


But you do delete effectively in the table, because if so, just use one this.clouse(); and call the method that loads the date Grid again that I will do a new search with the deleted lines.

Browser other questions tagged

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