I'm extending the ComboBox class in VB.NET and I'm running into a problem prepopulating the collection. I try to do so by using Me.Items.Add() calls in the New() sub. However, once I place the control on a form in the form designer, Visual Studio automatically adds those items to the collection in form designer, then they are added again at runtime. How can I make them only added once?
A:
i think you have to check DesignMode property.
in Constructor code you have to add
if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) then
this.Items.Add("test")
endif
if( not DesignMode) then ' not working
//add your items
endif
Hasu
2010-09-24 18:45:57
I did that, but it's still listing everything twice.
BlueJ774
2010-09-24 19:21:48
try this if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) { this.Items.Add("test"); }
Hasu
2010-09-24 19:40:20