Assembly, controls & initialization

  • Thread starter Thread starter Cedric
  • Start date Start date
C

Cedric

Hi,

I'm creating a c# assembly with many controls: lookup
comboboxes such as country & currency comboboxes.

I want this assembly to be used by many windows
applications & it shouldn't care how it gets the lookup
data (Web service, remoting, direct).

I looks like this:
namespace ISA.WinUserControls
{
/// <summary>
/// Summary description for cbCountries.
/// </summary>
public class cbCountries:
Syncfusion.Windows.Forms.Tools.ComboBoxAdv
{
private
ISA.BE.dsLookup.countriesDataTable Countries;

public cbCountries()
{
this.FlatStyle =
Syncfusion.Windows.Forms.Tools.ComboFlatStyle.System;
}
public cbCountries(
ISA.BE.dsLookup.countriesDataTable t): this()
{
DataTable = t;

}
public ISA.BE.dsLookup.countriesDataTable
DataTable
{
set
{
Countries = value;
DataSource = Countries;
ValueMember =
Countries.Columns[0].ColumnName;
DisplayMember =
Countries.Columns[1].ColumnName;
}
}
}
}

Somewhere, the application initializes one and for all an
ISA.BE.dsLookup & pass the right table to the constructor
of the control.

The problem is, the VS.Net designer always initialize
controls with a constructor without parameters in the
InitializeComponent() function, e.g. this.cbCountry1 =
new ISA.WinUserControls.cbCoutries(); If I change it to
this.cbCountry1 = new ISA.WinUserControls.cbCoutries
(dsLookupSingleton.Countries), it works but should I
change the form/component with the designer later,
everything breaks.

A better solution would be to somehow initialize the
assembly once, which would initialize every control with
the data once. Does anybody know how to do it?

Thanks,

Cedric
 
I think you cannot do so.

Regards,
Justin Wan
Microsoft Partner Online Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
You're probably better off using a property in this case, rather than a
parameter to the constructor.
 
Back
Top