Persisting a control property to the Designer.cs file (How do I make a control's property serialise correctly to a form's designer.cs file?)How do I make an object's variable name editable in the designer?C# Enum List/Collection on User/Web Control design time support?Get properties and values from unknown objectUsing Unity, how do I resolve a name value to a static class property?How to add designer support for Point property on custom control?Persisting a control property to the Designer.cs fileKeep Control's default property from being included into Design-time serialisationImplementing TypeConverter for Windows FormsWinforms Designer custom property does not keep its value when I buildStrange bug with VS 2012 Winform designer and custom controls
Is it possible to have battery technology that can't be duplicated?
Is it good practice to create tables dynamically?
If absolute velocity does not exist, how can we say a rocket accelerates in empty space?
Is it true that "only photographers care about noise"?
How can I find out about the game world without meta-influencing it?
Undocumented incompatibility between changes and siunitx?
Is all-caps blackletter no longer taboo?
Why does there seem to be an extreme lack of public trashcans in Taiwan?
Fastest way from 8 to 7
Am I allowed to determine tenets of my contract as a warlock?
Purpose of cylindrical attachments on Power Transmission towers
ISP is not hashing the password I log in with online. Should I take any action?
Can a 40amp breaker be used safely and without issue with a 40amp device on 6AWG wire?
David slept with Bathsheba because she was pure?? What does that mean?
Is the first of the 10 Commandments considered a mitzvah?
Must a CPU have a GPU if the motherboard provides a display port (when there isn't any separate video card)?
Idiom for 'person who gets violent when drunk"
Was the Lonely Mountain, where Smaug lived, a volcano?
Does WiFi affect the quality of images downloaded from the internet?
How was nut milk made before blenders?
French citizen, did I need a visa in 2004 and 2006 when I visited as a child?
Why is linear regression results so much different from Poisson regression?
My mom's return ticket is 3 days after I-94 expires
Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes
Persisting a control property to the Designer.cs file (How do I make a control's property serialise correctly to a form's designer.cs file?)
How do I make an object's variable name editable in the designer?C# Enum List/Collection on User/Web Control design time support?Get properties and values from unknown objectUsing Unity, how do I resolve a name value to a static class property?How to add designer support for Point property on custom control?Persisting a control property to the Designer.cs fileKeep Control's default property from being included into Design-time serialisationImplementing TypeConverter for Windows FormsWinforms Designer custom property does not keep its value when I buildStrange bug with VS 2012 Winform designer and custom controls
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How do I make a control's property (specifically in this case a PointF type) serialise correctly to a form's designer.cs file?
I'm now looking at a subclass of the CodeDomSerializer, which does change the designer.cs code (adding a comment as per the example on that page works) but it seems that I can only apply it to the CustomControl class as a whole, and try to modify the base serialization to replace the CodeCastExpression with a CodeObjectCreateExpression. This seems like a really messy way of doing things, though...
I have a custom control which contains a property of type PointF. When this control is added to a form and is saved, the designer.cs file doesn't say something like:
...
this.customControl.LocationF = new System.Drawing.PointF(50.0f, 50.0f);
...
Instead, it says this:
...
this.customControl.LocationF = ((System.Drawing.PointF)(resources.GetObject("customControl.LocationF")));
...
I've been trying to "persuade" this property to properly serialise to the designer file, and my search has turned up a couple of promising leads:
DesignerSerializerAttribute, but I can't make sense of exactly what it's supposed to do, or how to use it.
A TypeConverter which can convert to an InstanceDescriptor (looking at the example given by MSDN for Generating Code for Custom Types).
I've followed the example given in the MSDN example, replacing Point with PointF and int with float, then my CustomControl looks like this:
public class CustomControl : Button
[Category("Layout")]
[TypeConverter(typeof(PointFConverter))]
public PointF LocationF
get return this.Location;
set this.Location = new Point((int)value.X, (int)value.Y);
As far as I can see, this should work, but it seems to have no effect on how it's serialised to the designer file.
Something else I've just noticed - the PointFConverter isn't actually ever used when generating the designer.cs file - it's only used when reading or writing the value of the property in the properties box in design mode... Maybe this TypeConverter thing is a dead end...
c# controls designer
add a comment |
How do I make a control's property (specifically in this case a PointF type) serialise correctly to a form's designer.cs file?
I'm now looking at a subclass of the CodeDomSerializer, which does change the designer.cs code (adding a comment as per the example on that page works) but it seems that I can only apply it to the CustomControl class as a whole, and try to modify the base serialization to replace the CodeCastExpression with a CodeObjectCreateExpression. This seems like a really messy way of doing things, though...
I have a custom control which contains a property of type PointF. When this control is added to a form and is saved, the designer.cs file doesn't say something like:
...
this.customControl.LocationF = new System.Drawing.PointF(50.0f, 50.0f);
...
Instead, it says this:
...
this.customControl.LocationF = ((System.Drawing.PointF)(resources.GetObject("customControl.LocationF")));
...
I've been trying to "persuade" this property to properly serialise to the designer file, and my search has turned up a couple of promising leads:
DesignerSerializerAttribute, but I can't make sense of exactly what it's supposed to do, or how to use it.
A TypeConverter which can convert to an InstanceDescriptor (looking at the example given by MSDN for Generating Code for Custom Types).
I've followed the example given in the MSDN example, replacing Point with PointF and int with float, then my CustomControl looks like this:
public class CustomControl : Button
[Category("Layout")]
[TypeConverter(typeof(PointFConverter))]
public PointF LocationF
get return this.Location;
set this.Location = new Point((int)value.X, (int)value.Y);
As far as I can see, this should work, but it seems to have no effect on how it's serialised to the designer file.
Something else I've just noticed - the PointFConverter isn't actually ever used when generating the designer.cs file - it's only used when reading or writing the value of the property in the properties box in design mode... Maybe this TypeConverter thing is a dead end...
c# controls designer
add a comment |
How do I make a control's property (specifically in this case a PointF type) serialise correctly to a form's designer.cs file?
I'm now looking at a subclass of the CodeDomSerializer, which does change the designer.cs code (adding a comment as per the example on that page works) but it seems that I can only apply it to the CustomControl class as a whole, and try to modify the base serialization to replace the CodeCastExpression with a CodeObjectCreateExpression. This seems like a really messy way of doing things, though...
I have a custom control which contains a property of type PointF. When this control is added to a form and is saved, the designer.cs file doesn't say something like:
...
this.customControl.LocationF = new System.Drawing.PointF(50.0f, 50.0f);
...
Instead, it says this:
...
this.customControl.LocationF = ((System.Drawing.PointF)(resources.GetObject("customControl.LocationF")));
...
I've been trying to "persuade" this property to properly serialise to the designer file, and my search has turned up a couple of promising leads:
DesignerSerializerAttribute, but I can't make sense of exactly what it's supposed to do, or how to use it.
A TypeConverter which can convert to an InstanceDescriptor (looking at the example given by MSDN for Generating Code for Custom Types).
I've followed the example given in the MSDN example, replacing Point with PointF and int with float, then my CustomControl looks like this:
public class CustomControl : Button
[Category("Layout")]
[TypeConverter(typeof(PointFConverter))]
public PointF LocationF
get return this.Location;
set this.Location = new Point((int)value.X, (int)value.Y);
As far as I can see, this should work, but it seems to have no effect on how it's serialised to the designer file.
Something else I've just noticed - the PointFConverter isn't actually ever used when generating the designer.cs file - it's only used when reading or writing the value of the property in the properties box in design mode... Maybe this TypeConverter thing is a dead end...
c# controls designer
How do I make a control's property (specifically in this case a PointF type) serialise correctly to a form's designer.cs file?
I'm now looking at a subclass of the CodeDomSerializer, which does change the designer.cs code (adding a comment as per the example on that page works) but it seems that I can only apply it to the CustomControl class as a whole, and try to modify the base serialization to replace the CodeCastExpression with a CodeObjectCreateExpression. This seems like a really messy way of doing things, though...
I have a custom control which contains a property of type PointF. When this control is added to a form and is saved, the designer.cs file doesn't say something like:
...
this.customControl.LocationF = new System.Drawing.PointF(50.0f, 50.0f);
...
Instead, it says this:
...
this.customControl.LocationF = ((System.Drawing.PointF)(resources.GetObject("customControl.LocationF")));
...
I've been trying to "persuade" this property to properly serialise to the designer file, and my search has turned up a couple of promising leads:
DesignerSerializerAttribute, but I can't make sense of exactly what it's supposed to do, or how to use it.
A TypeConverter which can convert to an InstanceDescriptor (looking at the example given by MSDN for Generating Code for Custom Types).
I've followed the example given in the MSDN example, replacing Point with PointF and int with float, then my CustomControl looks like this:
public class CustomControl : Button
[Category("Layout")]
[TypeConverter(typeof(PointFConverter))]
public PointF LocationF
get return this.Location;
set this.Location = new Point((int)value.X, (int)value.Y);
As far as I can see, this should work, but it seems to have no effect on how it's serialised to the designer file.
Something else I've just noticed - the PointFConverter isn't actually ever used when generating the designer.cs file - it's only used when reading or writing the value of the property in the properties box in design mode... Maybe this TypeConverter thing is a dead end...
c# controls designer
c# controls designer
asked Mar 25 at 0:31
정유진정유진
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329937%2fpersisting-a-control-property-to-the-designer-cs-file-how-do-i-make-a-controls%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329937%2fpersisting-a-control-property-to-the-designer-cs-file-how-do-i-make-a-controls%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown