F
Fred Flintstone
This is driving me crazy. I've put together a perfect, easy example of
the problem. What I'm doing is creating a custom control, prepopulated
with 4 items when dropped on a form:
- Create a new Control Library project.
- Inherit System.Windows.Forms.Combobox
- In New(), add this:
Me.Items.Add("Test1")
Me.Items.Add("Test2")
Me.Items.Add("Test3")
Me.Items.Add("Test4")
- Build.
- Start a sample project.
- Drop the new control on the form
- Run.
- Pull down combo:
The combo containts Test1 - Test4, TWICE.
The problem is, when the new control is dropped on a form, it adds
this to the "Windows Form Designer Generated Code":
'
'TestCombo1
'
Me.TestCombo1.Items.AddRange(New Object() {"Test1", "Test2", "Test3",
"Test4"})
Me.TestCombo1.Location = New System.Drawing.Point(64, 80)
Me.Morecode...
I can't write any pre-initialized controls because the initialization
is always copied to the application it's being used in, duplicating
the code as demonstrated here. How do I prevent inheritance of the
iniitialization code? (or any code for that matter)
Thanks!!!
the problem. What I'm doing is creating a custom control, prepopulated
with 4 items when dropped on a form:
- Create a new Control Library project.
- Inherit System.Windows.Forms.Combobox
- In New(), add this:
Me.Items.Add("Test1")
Me.Items.Add("Test2")
Me.Items.Add("Test3")
Me.Items.Add("Test4")
- Build.
- Start a sample project.
- Drop the new control on the form
- Run.
- Pull down combo:
The combo containts Test1 - Test4, TWICE.
The problem is, when the new control is dropped on a form, it adds
this to the "Windows Form Designer Generated Code":
'
'TestCombo1
'
Me.TestCombo1.Items.AddRange(New Object() {"Test1", "Test2", "Test3",
"Test4"})
Me.TestCombo1.Location = New System.Drawing.Point(64, 80)
Me.Morecode...
I can't write any pre-initialized controls because the initialization
is always copied to the application it's being used in, duplicating
the code as demonstrated here. How do I prevent inheritance of the
iniitialization code? (or any code for that matter)
Thanks!!!