Hi,
I have a problem referencing the controls in a child class and as I am fairly new to c# I am not sure whether it is actually possible to do what I want to do..phew!! Basically I have a standard dialog that has apply/ok/cancel buttons. It also loads the data from the db depending on what textboxes appear on the form. However I would like to load these textboxes via child classes so that I can have 'StandardDialog' do all the work and have a bunch of custom dialogs that just have textboxes on them. Everything seems ok except that when i search through the controls it only finds the ones on the parent form. Can i reference the ones on the child class? Here is the code.
Hope someone can help!!
thanks, Martin
I have a problem referencing the controls in a child class and as I am fairly new to c# I am not sure whether it is actually possible to do what I want to do..phew!! Basically I have a standard dialog that has apply/ok/cancel buttons. It also loads the data from the db depending on what textboxes appear on the form. However I would like to load these textboxes via child classes so that I can have 'StandardDialog' do all the work and have a bunch of custom dialogs that just have textboxes on them. Everything seems ok except that when i search through the controls it only finds the ones on the parent form. Can i reference the ones on the child class? Here is the code.
Code:
class StandardDialog : System.Windows.Forms.Form
{
public StandardDialog()
{
InitializeComponent();
LoadData()
}
private void InitializeComponent()
{
// Ok,Cancel & Apply buttons here
}
protected void LoadData()
{
foreach (Control c in Controls)
{
//Load data from db
}
}
}
class SiteDialog : StandardDialog
{
public SiteDialog(): base()
{
InitializeComponent();
}
private void InitializeComponent()
{
// Textboxes loaded here
}
}
Hope someone can help!!
thanks, Martin