I would like to use some public methods from another forms. I'd like to know if there is a way to do this, I tried to put the method and the form in public, but when I try to call it into another form the method, it just dosnt appear anything.
here is my main form:
namespace GUI
{
public partial class frmPrincipal : Form
{
public frmPrincipal()
{
InitializeComponent();
}
private void categoriaToolStripMenuItem_Click(object sender, EventArgs e)
{
frmCadastroCategoria f = new frmCadastroCategoria();
f.ShowDialog();
f.Dispose();
}
private void categoriaToolStripMenuItem1_Click(object sender, EventArgs e)
{
frmConsultaCategoria f = new frmConsultaCategoria();
f.ShowDialog();
f.Dispose();
}
and this is the form that I try to call
public void LocalizarCategoria()
{
frmConsultaCategoria f = new frmConsultaCategoria();
f.ShowDialog();
if (f.codigo != 0)
{
DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
BLLCategoria bll = new BLLCategoria(cx);
ModeloCategoria modelo = bll.CarregaModeloCategoria(f.codigo);
txtCodigo.Text = modelo.CatCod.ToString();
txtNome.Text = modelo.CatNome;
alteraBotoes(3);
}
else
{
this.LimpaTela();
this.alteraBotoes(1);
}
f.Dispose();
}
I was trying to do something like:
{
LocalizarCategoria()
}
but I can't, it just dosn't find the method.