I have a User Control for typical CRUD like actions on my WinForm app.
Validate, Insert, Update, Clear, Cancel, and Delete.
On every form I put this on I end up adding the click event, ucPersonNav.btnValidate.Click += new EventHandler(btnValidate_Click);
, for every button.
What I am wondering is can I have the Events be on the User Control themselves and just have them point to a Method that I override on a Form by Form basis?
Something like this -->
namespace psUserControls
{
using System;
using DevExpress.XtraEditors;
public partial class ucVIUCCDwithWhoDoneIt : XtraUserControl
{
public ucVIUCCDwithWhoDoneIt()
{
InitializeComponent();
}
private void btnValidate_Click(object sender, EventArgs e)
{
ValidateEvent();
}
}
}
And then on a Form have this -->
void ValidateEvent()
{
if (dxValidDiagnosis.Validate())
{
if (planDiagnosisID != 0)
{
ucNavDiagnosis.btnUpdate.Enabled = true;
ucNavDiagnosis.btnDelete.Enabled = true;
}
ucNavDiagnosis.btnInsert.Enabled = true;
}
}
Is this feasible? Is it idiotic? If Yes then No then what steps do I need to take to make this work?
Thanks