Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3940986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:29:11+00:00 2026-05-20T00:29:11+00:00

My custom control sets the values I want in the Properties for Anchor on

  • 0

My custom control sets the values I want in the Properties for Anchor on my Custom Label.

With Serializable set to Visible I’m getting the code generated for run-time, which I didn’t with type Content, but the control in the designer has the Anchor values a Label is given, (Left and Top), so to get the correct behaviour in the designer needs a manual (non-)change to the Anchor property.

I don’t really want to write a designer to make this work (at my rate of progress I don’t think that’s wise!), is there an easier way?

public:
 [DesignerSerializationVisibility(DesignerSerializationVisibility::Visible)]
  virtual property System::Windows::Forms::AnchorStyles Anchor
   {
    System::Windows::Forms::AnchorStyles get() override
     {
      return static_cast<System::Windows::Forms::AnchorStyles
       ((System::Windows::Forms::AnchorStyles::Top
       | System::Windows::Forms::AnchorStyles::Left) 
       | System::Windows::Forms::AnchorStyles::Right);;
     }

    void set(System::Windows::Forms::AnchorStyles x) override
     {
      __super::Anchor = static_cast<System::Windows::Forms::AnchorStyles
       ((System::Windows::Forms::AnchorStyles::Top
       | System::Windows::Forms::AnchorStyles::Left) 
       | System::Windows::Forms::AnchorStyles::Right);

     }
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:29:11+00:00Added an answer on May 20, 2026 at 12:29 am

    You are hardcoding the property value. So assign the value in the constructor, make it non-browsable so it won’t show up in the properties window and ensure that the value cannot be changed and doesn’t get serialized. Like this:

    ref class MyControl : Control {
    public:
        MyControl() {
            __super::Anchor = AnchorStyles::Top | AnchorStyles::Left | AnchorStyles::Right;
        }
    
        [Browsable(false), EditorBrowsable(EditorBrowsableState::Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility::Hidden)]
        virtual property System::Windows::Forms::AnchorStyles Anchor {
            AnchorStyles get() override {
                return __super::Anchor;
            }
            void set(AnchorStyles) override {
                // do nothing
            }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control that exposes a property. When I set it using
I've made a custom control with values for start, current, and end times. The
My custom control uses a ScrollViewer and I want to determine when the user
I am trying to make a custom control in WPF. I want it to
I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).
I'm implementing a custom control and in this control I need to write a
I have a custom control that inherits from WebControl and implements IValidator, but I
Hopefully some Custom Control Designers/Builders can help I'm attempting to build my first custom
I have a custom control that has the following prototype. Type.registerNamespace('Demo'); Demo.CustomTextBox = function(element)
I'm creating a custom control, part of which is using the Graphics class to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.