3
I have a form
base that will be the form
'Dad, with three buttons on it.
Add, Delete and Change.
I’m gonna use the formbase
to standardize my registration screens, so each registration screen when you click 'Record', will perform a different recording routine.
So I have this:
class frmCadastroFuncionario: Views.formulariobase
{
//herdando os botoes e o evento 'onclick'
}
Class formulariobase
{
public void Altera(string nome)
{
if (this.Form.Name.ToString() == "FuncionarioCadastro")
//faça isso
}
}
So when I call the alter function, I have to see what I’m going to perform inside the if
because it depends on the form
that I call the alters function will make it different. But this if
that I did does not work. So I wanted to know if using inheritance has how to know form
using the visual and event heritage of the formbase
.
Thanks for the example will really help me, but in the case of the 'On click' event of the button that c# provides, when I am in the form that is inheriting it ignores the event that I implement there, So from what I understand I have to make it virtual in the base form and then override the frmCadastroFuncinario ? I am in the service(I can not test at the moment), but I thank you from now on the answer!!
– Leonardo
I cannot say why this is not covered in your question. Open a new question by putting these details. C# provides nothing. Your code provides something. You should not ignore it if it is correct. But you would need to analyze the actual code. The
virtual
only serves to be able to exchange the implementation. Inheritance is automatic, unless the method isprivado
. This may be the case.– Maniero
OK ! Thank you very much !
– Leonardo
Coming home I got the expected result ! The event 'Onclick' comes private so just put it as virtual public and implement it in the child form with override! Thanks again and that’s what I always say, sharing knowledge and good manners of OO is how we learn! A great hug.
– Leonardo