P
Peter
Hello
I will use inherited comboboxes to provide Application wide
Information in all Dialogs e.g.
-Status Information from enum's
-Simple Information from the database (e.g. unit of measurement, kg,
m, ….)
I inherit my own combobox and fill it in the constructor
public class MyComboBox:Combobox
{
public MyComboBox()
{
// fill from database or enum
// e.g.
for (int I=1; I<10; I++)
this.Items.Add(I);
}
}
Using myCombobox in the Form-Designer is easy.
Starting the application all Items in myCombobox are duplicated!
Because the form designer create code in the InitializeComponent()
this.comboBoxAktiv.Items.AddRange(new object[] {
1,
2,
3,
…,
9});
obviously the Form Designer create a instance of myCombobox and use
the Content to build an array of Objects using add range…
I cant believe that. Using inheritance makes no sense.
Particularly filling from database is impossible.
Is there a possibility to prevent the code generation ?
Peter
I will use inherited comboboxes to provide Application wide
Information in all Dialogs e.g.
-Status Information from enum's
-Simple Information from the database (e.g. unit of measurement, kg,
m, ….)
I inherit my own combobox and fill it in the constructor
public class MyComboBox:Combobox
{
public MyComboBox()
{
// fill from database or enum
// e.g.
for (int I=1; I<10; I++)
this.Items.Add(I);
}
}
Using myCombobox in the Form-Designer is easy.
Starting the application all Items in myCombobox are duplicated!
Because the form designer create code in the InitializeComponent()
this.comboBoxAktiv.Items.AddRange(new object[] {
1,
2,
3,
…,
9});
obviously the Form Designer create a instance of myCombobox and use
the Content to build an array of Objects using add range…
I cant believe that. Using inheritance makes no sense.
Particularly filling from database is impossible.
Is there a possibility to prevent the code generation ?
Peter