Over a long period, some users have reported problems with code generated in the function InitializeComponent(), looking something like this:
this.labelX9.BackgroundStyle.Class = global::YourProject.MultiLang._668;
The reference to MultiLang obviously implicates the Multi-Language Add-In, but the code in InitializeComponent() is neither generated nor modified by the Add-In. This effect has always baffled me.
Now I think I know what is happening, and I can illustrate it with a sample program. This sample contains several parts, which I will try to describe in detail
This sample defines
I have made the sample in VB, but it could just as easily be in C#. I am sure that there is no difference.
Imports System.ComponentModel
<TypeConverterAttribute(GetType(ExpandableObjectConverter))> _
Public Class MyObject
Private mEmpty As String = ""
Private mOne As String = "One"
Private mTwo As String = "Two"
<Localizable(True)> _
Public Property Empty as String
Get
Return mEmpty
End Get
Set(ByVal value As String)
mEmpty = value
End Set
End Property
<Localizable(True)> _
Public Property One as String
Get
Return mOne
End Get
Set(ByVal value As String)
mOne = value
End Set
End Property
Public Property Two as String
Get
Return mTwo
End Get
Set(ByVal value As String)
mTwo = value
End Set
End Property
End Class
This class contains three properties:
| Name | Attributes | Initial value |
| Empty | Localizable | "" |
| One | Localizable | "One" |
| Two | None | "Two" |
The class itself has the attribute <TypeConverterAttribute(GetType(ExpandableObjectConverter))>, which means that it is will be expandable in the properties grid.
This is the user defined code in the UserControl. Obviously there is more code in the .designer.vb file, but that does not particularly interest us.
Imports System.ComponentModel
Public Class ControlWithObject
Private mObject As New MyObject
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public ReadOnly Property ChildObject as MyObject
Get
Return mObject
End Get
End Property
End Class
This UserControl has a single property named ChildObject, of type MyObject.
I have placed a single instance of the UserControl ControlWithObject on the form.
As you can see, the ChildObject property can be expanded in the properties window.
This form contains no user defined code.
I have added three resource strings to the project, containing the same strings as the properties in the MyObject class.
I have named the resources Empty, One and Two, corresponding to their contents, but the names are unimportant.