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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:51:13+00:00 2026-06-11T21:51:13+00:00

Let’s say we have the following class Cell , which is composed of a

  • 0

Let’s say we have the following class Cell, which is composed of a Label control:

class Cell : UserControl
{
    Label base;

    public Cell(Form form)
    {
        base = new Label();
        base.Parent = form;        
        base.Height = 30;
        base.Width = 30;
    }
} 

public partial class Form1 : Form
{ 
    Label label = new Label();

    public Form1()
    {
        InitializeComponent();

        Cell cell = new Cell(this);
        cell.Location = new Point(150, 150);   //this doesnt work            
        label.Location = new Point(150,150);   //but this does
    }
}

A single Cell will display in the Form, but anchored to the top left (0,0) position.

Setting the Location property to a new Point with any other coordinates does nothing, as the Cell will remain in the upper left.

However, if one were to create a new Label and then attempt to set its location, the label would be moved.

Is there a way to do this on my Cell object?

  • 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-11T21:51:14+00:00Added an answer on June 11, 2026 at 9:51 pm

    I think your main problem is that you are not adding the controls to a container correctly.

    First, you need to add the inner Label to the Cell;

    class Cell : UserControl
    {       
        Label lbl;
    
        public Cell()
        {
            lbl = new Label();
            lbl.Parent = form;        
            lbl.Height = 30;
            lbl.Width = 30;
            this.Controls.Add(lbl); // label is now contained by 'Cell'
        }
    } 
    

    Then, you need to add the Cell to the Form;

    Cell cell = new Cell();
    form.Controls.Add(cell);
    

    Also; ‘base’ is a reserved word, so you can’t name the inner label control such.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following class hierarchy: TaskViewer inherits from ListViewer<Task> which in
Let's say I have the following class hierarchy in C++: class Base; class Derived1
Let's say I have defined the following class: public abstract class Event { public
let say i have following class: class Shape { public int widht; public List<Point>
Let's say I have the following class definition : List<SomeClass>... public class SomeClass {
Let's say I have the following class structure: class Car; class FooCar : public
Let's say I have the following class hierarchy: class Base { protected: virtual void
Let's say I have the following class which I am not allowed to change:
Let's say I have the following class hierarchy (base interface included): IAction -> (abstract)
Let's say I have the following class structure (simplified from my real-world problem): Public

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.