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 7902271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:27:01+00:00 2026-06-03T09:27:01+00:00

How does one properly read values of custom control properties set via design time?

  • 0

How does one properly read values of custom control properties set via design time?

Currently, rows and columns are set in the properties list of the control (vs.net as ide), however both properties return 0 when read from the constructor of the control. I suspect the constructor is executing before the properties are assigned during start of application.

What is the correct way of doing this?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;

    namespace HexagonalLevelEditor.HexLogic{

        class HexGrid : System.Windows.Forms.Panel {

            public HexGrid() {
                for(int c = 0; c < this.Columns; ++c) {
                    for(int r = 0; r < this.Rows; ++r) {
                        HexCell h = new HexCell();
                        h.Width = 200;
                        h.Height = 200;
                        h.Location = new System.Drawing.Point(c*200, r*200);
                        this.Controls.Add(h);
                    }
                }
            }

            private void InitializeComponent() {
                this.SuspendLayout();
                this.ResumeLayout(false);
            }

            private int m_rows;
            [Browsable(true), DescriptionAttribute("Hexagonal grid row count."), Bindable(true)]
            public int Rows {
                get {
                    return m_rows;
                }

                set {
                    m_rows = value;
                }
            }

            private int m_columns;
            [Browsable(true), DescriptionAttribute("Hexagonal grid column count."), Bindable(true)]
            public int Columns { 
                get{
                    return m_columns;
                }

                set {
                    m_columns = value;
                }
            }
        }
    }
  • 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-06-03T09:27:02+00:00Added an answer on June 3, 2026 at 9:27 am

    Ultimately, you really want to remake the grid whenever either of the properties Rows / Columns change. So you should have a method which remakes the grid, and call it whenever the properties are being set.

    public void RemakeGrid()
    {
        this.ClearGrid();
    
        for(int c = 0; c < this.Columns; ++c)
        {
            for(int r = 0; r < this.Rows; ++r)
            {
                HexCell h = new HexCell();
                h.Width = 200;
                h.Height = 200;
                h.Location = new System.Drawing.Point(c*200, r*200);
                this.Controls.Add(h);
            }
        }
    }
    
    private int m_rows;
    
    [Browsable(true), DescriptionAttribute("Hexagonal grid row count."), Bindable(true)]
    public int Rows
    {
        get
        {
            return m_rows;
        }
        set
        {
            m_rows = value;
            this.RemakeGrid();
        }
    }
    
    // Same goes for Columns...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one go about properly analyzing the requirements of a client in terms
How does one choose if someone justify their design tradeoffs in terms of optimised
How does one read the request body in ASP.NET? I'm using the REST Client
How does one change / modify the Result property of a web service operation?
does one perform better over the other in terms of indexing/quering etc ? e.g.
How does one test a method that does some interactions with the local D-Bus
How does one compare single character strings in Perl? Right now, I'm tryin to
How does one convert from an int or a decimal to a float in
How does one obtain programmatically a reference to the object of which a FieldInfo
How does one find out which controller or which action they are in from

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.