1
I would like when the user selects a particular Tab, to immediately open an Openfiledialog box.
I already have this Savefiledialog, but it’s in the button click method:
private void btnGuardar_Click(object sender, EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.InitialDirectory = @"C:\Ficheiros\";
save.Title = "Salvar Ficheiro";
save.Filter = "txt files (*.txt)|*txt|All files (*.*)|*.*";
if (save.ShowDialog() == DialogResult.Cancel) return;
if (save.ShowDialog() == DialogResult.OK)
{
StreamWriter escritor;
if (tabControl1.SelectedTab == tpFicheiro)
{
escritor = new StreamWriter(save.FileName, false, Encoding.Default);
escritor.WriteLine(tbFicheiro1.Text);
}
else
{
escritor = new StreamWriter(save.FileName, true, Encoding.Default);
escritor.WriteLine(tbFicheiro2.Text);
}
escritor.Flush();
escritor.Close();
}
Could someone help me with this?
– F. Rocha