0
I’m instantiating a form with a single textbox
just to put the password to release the button action.
The button has the function of exporting the data contained in datagridview
for a spreadsheet in Excel, I’m trying to do this way:
private void btnExportar_Click(object sender, EventArgs e)
{
formExportar form = new formExportar();
form.ShowDialog();
if (exportar.txtsenha.Text == "123")
{
//código para exportar arquivos para o excel
}
else
{
MetroFramework.MetroMessageBox.Show(this, "Senha incorreta", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
In case the formExportar
is the authentication form where I enter the password, I am instantiating it in the main form this way:
public partial class TelaInicio : MetroFramework.Forms.MetroForm
{
internal formExportar exportar = new formExportar();
public TelaInicio(formExportar exportar)
{
InitializeComponent();
this.exportar = exportar;
}
But by the fact of the button OK
that exists in the formExportar
not being executed turns out to be no action taking.
I also tried to play all the export code on formExportar
instead of leaving in the main form but this ends up causing an error by the fact that there is no DataSource
in that form, I really don’t know how to proceed with this.