I derived from a ToolStripComboBox in order to create one that encapsulates a percentage picking dropdown. The goal is to have all of the validation and string parsing in the derived control. The parent simply receives an event when the percentage chosen has changed, and it can access a public integer for getting and setting the percentage.
The problem I have is that in the designer file for the parent control which I place my derived control on, it constantly keeps adding a full set of strings using the ComboBox.Items.AddRange method. In the constructor for my derived control I have the following:
foreach (int i in percentages)
{
ComboBox.Items.Add(String.Format("{0}%", i));
}
Over time these values accumulate in the designer file many, many times over. I don’t know how to make the Items property hidden since it’s not virtual. I want to suppress this flooding of my designer file.
Example of my designer file:
this.zoom_cbo.Items.AddRange(new object[] {
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"300%",
"400%",
"600%",
"800%",
"1600%"});
Since it’s a derived list that the user is just selecting from, try adding this to your derived combo box to prevent the serialization of the items: