T
Tim A.
Hello gurus!
In my C# project I have a localized form that I use as the prototype for two
others. The prototype form has a ListBox control data bound to an ArrayList
containing data elements of a custom class type. At design time its Items
collection is empty and is populated by data binding only when the
application is executed and the underlying ArrayList collection is created.
The inherited forms' ListBox controls seem to somehow mysteriously inherit
not only the properties of the prototype form's ListBox control, but also
its Items collection. It sounds crazy, but I get errors at compile time
which are caused by the code Windows Forms Designer automatically inserts
into the InitializeComponent() method. This is what it looks like:
this.lstItems.Items.AddRange(new object[] {
((object)(resources.GetObject("lstItems.Items"))),
((object)(resources.GetObject("lstItems.Items1"))),
((object)(resources.GetObject("lstItems.Items2"))),
((object)(resources.GetObject("lstItems.Items3")))});
This line is inserted automatically every time I save the inherited form.
It seems that VS caches the number of elements in the Items collection the
last time the application is run in debug mode and assumes the elements
exist in the resource file, which they don't.
Any ideas how to get rid of this annoying behaviour?
P.S. If you reply directly, please remove the anti-spamming proclamation
from my e-mail address.
In my C# project I have a localized form that I use as the prototype for two
others. The prototype form has a ListBox control data bound to an ArrayList
containing data elements of a custom class type. At design time its Items
collection is empty and is populated by data binding only when the
application is executed and the underlying ArrayList collection is created.
The inherited forms' ListBox controls seem to somehow mysteriously inherit
not only the properties of the prototype form's ListBox control, but also
its Items collection. It sounds crazy, but I get errors at compile time
which are caused by the code Windows Forms Designer automatically inserts
into the InitializeComponent() method. This is what it looks like:
this.lstItems.Items.AddRange(new object[] {
((object)(resources.GetObject("lstItems.Items"))),
((object)(resources.GetObject("lstItems.Items1"))),
((object)(resources.GetObject("lstItems.Items2"))),
((object)(resources.GetObject("lstItems.Items3")))});
This line is inserted automatically every time I save the inherited form.
It seems that VS caches the number of elements in the Items collection the
last time the application is run in debug mode and assumes the elements
exist in the resource file, which they don't.
Any ideas how to get rid of this annoying behaviour?
P.S. If you reply directly, please remove the anti-spamming proclamation
from my e-mail address.