Hi
I'm trying to create various inherited WinComboEditors with predefined item lists so that I can easily reuse them on my forms
I have done so, but am finding that the item lists are doubling and tripling up their contents on the final form
When I examine the designer code of the hosting form I see the list elements created again. making changes to this only compounds the error
any help would be gratefully recieved
here is the component code to aid in recreating;
<
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial
Class ipUltraComboEditorYesNo
Inherits Infragistics.Win.UltraWinEditors.UltraComboEditor
'Control overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Control Designer
Private components As System.ComponentModel.IContainer
' NOTE: The following procedure is required by the Component Designer
' It can be modified using the Component Designer. Do not modify it
' using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim ValueListItem1 As Infragistics.Win.ValueListItem = New Infragistics.Win.ValueListItem
Dim ValueListItem2 As Infragistics.Win.ValueListItem = New Infragistics.Win.ValueListItem
CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ipUltraComboEditorYesNo
Me.DropDownStyle = Infragistics.Win.DropDownStyle.DropDownList
ValueListItem1.DataValue =
"ValueListItem0"
ValueListItem1.DisplayText =
"Yes"
ValueListItem2.DataValue =
"ValueListItem1"
ValueListItem2.DisplayText =
"No"
Me.Items.AddRange(New Infragistics.Win.ValueListItem() {ValueListItem1, ValueListItem2})
Me.LimitToList = True
CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End
Class
There is a similar discussion in the following thread:http://forums.infragistics.com/forums/t/33607.aspx
Thanks for getting back to me.
To be honest I wanted to create a control that I could just drop on a form and it do what I wanted and not have to add more code to initialise every time i want to use my control.
I was looking for some events on the control - like an onLoad in which I could create the list at run time maybe.
I was also toying with the me.DesignMode flag by placing my code in the new() but it seems the me.designMode flag isnt initialised when the constructor is called in the designer so that the initalising code would only be called at run time
Is this a limitation with Visual Studio as I notice with inherited controls if you change a base property that you previously changed, the change doesn't ripple up because it is overwritten in the form.designer code
Brilliant, I'll have to check it a bit more, but that has worked!
Here is the source code for my control if anybody wants to know how to do it
Public Class ipUltraComboEditorYesNo
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
If Not Me.DesignMode Then
ValueListItem1.DataValue = "ValueListItem0"
ValueListItem1.DisplayText = "Yes"
ValueListItem2.DataValue = "ValueListItem1"
ValueListItem2.DisplayText = "No"
End Class
I found the following post, which talks about overriding the OnCreateControl() method of your inherited control. While this is related to adding editor buttons to a WinTextEditor, the underlying issue is the same, and so the solution (with some code detail in the subsequent post) sounds like what you're after:http://forums.infragistics.com/forums/p/10067/39864.aspx#39864