Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
GeneralRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
BillWoodruff25-May-15 7:54
professionalBillWoodruff25-May-15 7:54 
AnswerRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
Richard Deeming22-May-15 7:11
mveRichard Deeming22-May-15 7:11 
GeneralRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
BillWoodruff22-May-15 21:27
professionalBillWoodruff22-May-15 21:27 
GeneralRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
BillWoodruff24-May-15 22:46
professionalBillWoodruff24-May-15 22:46 
AnswerRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
Pete O'Hanlon22-May-15 8:06
mvePete O'Hanlon22-May-15 8:06 
GeneralRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
BillWoodruff22-May-15 21:33
professionalBillWoodruff22-May-15 21:33 
GeneralRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
Pete O'Hanlon22-May-15 21:47
mvePete O'Hanlon22-May-15 21:47 
AnswerRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
Alan N22-May-15 14:15
Alan N22-May-15 14:15 
I think your unwanted designer initialisation can be suppressed with the rarely mentioned System.ComponentModel.DesignerSerializationVisibilityAttribute.

C#
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Dictionary<int, string> IntToString {
  get { return dic; }
  set { dic = value; }
}


Something I noticed was that my test code without the Hidden attribute was not initialising the property with null but with a valid dictionary object deserialised from the host Form's resource, i.e. from the Form.resx file.

C#
this.someComponent1.IntToString = ((System.Collections.Generic.Dictionary<int, string>)(resources.GetObject("someComponent1.IntToString")));


I could only get explicit initialisation of the property to null in the generated code when it had not been assigned in the SomeComponents constructor. It looks as if the designer creates a SomeComponents object via the parameterless constructor and reads the actual property values for subsequent assignment in the generated code. Your parameterless constructor does not initialise the dictionary and therefore the generated code initialises the property to null.

This is all rather confusing because the generated code does not use the parameterless constructor.

My working hypothesis is that
1) The designer creates a Control object using the parameterless constructor
2) Reads the property values from the object
3) Serialises non primitive values to a resource file
3) Generates object creation/initialisation code which reassigns the previously read property values
4) Properties marked with DesignerSerializationVisibility.Hidden are ignored

I think you'll have to do some experimentation!

Alan.
GeneralRe: way around limitations of WinForms treatment of Public Proprties implementing an Interface ? Pin
BillWoodruff22-May-15 21:35
professionalBillWoodruff22-May-15 21:35 
QuestionHow to get the directory where DDL is installed Pin
Antonio Guedes22-May-15 6:14
Antonio Guedes22-May-15 6:14 
AnswerRe: How to get the directory where DDL is installed Pin
Eddy Vluggen22-May-15 6:56
professionalEddy Vluggen22-May-15 6:56 
GeneralRe: How to get the directory where DDL is installed Pin
Antonio Guedes22-May-15 10:06
Antonio Guedes22-May-15 10:06 
GeneralRe: How to get the directory where DDL is installed Pin
Richard Andrew x6422-May-15 12:28
professionalRichard Andrew x6422-May-15 12:28 
QuestionHow to implement Save As functionality in C# Pin
RajuPrasad8222-May-15 3:49
professionalRajuPrasad8222-May-15 3:49 
AnswerRe: How to implement Save As functionality in C# Pin
Dave Kreskowiak22-May-15 4:09
mveDave Kreskowiak22-May-15 4:09 
GeneralRe: How to implement Save As functionality in C# Pin
RajuPrasad8222-May-15 4:24
professionalRajuPrasad8222-May-15 4:24 
GeneralRe: How to implement Save As functionality in C# Pin
Dave Kreskowiak22-May-15 4:49
mveDave Kreskowiak22-May-15 4:49 
AnswerRe: How to implement Save As functionality in C# Pin
Eddy Vluggen22-May-15 4:23
professionalEddy Vluggen22-May-15 4:23 
GeneralRe: How to implement Save As functionality in C# Pin
RajuPrasad8222-May-15 5:49
professionalRajuPrasad8222-May-15 5:49 
GeneralRe: How to implement Save As functionality in C# Pin
Sascha Lefèvre22-May-15 5:57
professionalSascha Lefèvre22-May-15 5:57 
GeneralRe: How to implement Save As functionality in C# Pin
RajuPrasad8222-May-15 6:01
professionalRajuPrasad8222-May-15 6:01 
GeneralRe: How to implement Save As functionality in C# Pin
Sascha Lefèvre22-May-15 6:33
professionalSascha Lefèvre22-May-15 6:33 
AnswerRe: How to implement Save As functionality in C# Pin
CHill6022-May-15 8:14
mveCHill6022-May-15 8:14 
Questionobject reference not set to an instance of an object. Pin
abdo.kouta22-May-15 3:31
abdo.kouta22-May-15 3:31 
GeneralRe: object reference not set to an instance of an object. Pin
Sascha Lefèvre22-May-15 3:55
professionalSascha Lefèvre22-May-15 3:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.