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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:46:21+00:00 2026-05-31T09:46:21+00:00

I have been porting my C# / .NET 2.0 project over to Mono for

  • 0

I have been porting my C# / .NET 2.0 project over to Mono for use on other platforms, but this seems to have brought up a problem in the NATIVE WinForms implementation.

I have isolated the problem to the relationship between a Control’s (specifically, a Button) Anchor property, and it’s Location property’s Y-component. When the AnchorStyle property is set to Top, the origin of the Location property is the ClientArea of the form (excluding the Title Bar). Changing the Anchor to Bottom, however changes the origin to the Top-Left corner of the entire Window (including the Title Bar).

Here’s a small Form class which illustrates the difference:

public class RawCodeForm : Form
{
    public RawCodeForm()
    {
        Button b = new Button();
        b.Text = "Test";
        b.Location = new Point( 10, 10 );
        b.Size = new Size( 75, 23 );
        b.Anchor = AnchorStyles.Left | AnchorStyles.Top;
        //b.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;

        this.Controls.Add( b );
        this.Size = new Size( 100, 200 );
        this.Location = new Point( 100, 100 );
        this.Show();
    }
}

Try swapping the b.Anchor lines to see the change is position.

Is this a documented bug, or am I missing another property that needs to be set?


Edit: Thanks for pointing out that the Form starts as Size(300,300). I had assumed it was (0,0) until set.

Outside of the simple test form above, the problem now looks to be that the FormBorderStyle being changed later is causing the form to resize. My guess is that under Mono (or the host OS), the FormBorderStyle being changed resizes the ClientArea smaller, where-as the ClientSize area stays the same size in native WinForms.

  • 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-31T09:46:23+00:00Added an answer on May 31, 2026 at 9:46 am

    This is because you change the size of the form after having added the button. Change it before

    this.Size = new Size(100, 200);
    this.Location = new Point(100, 100);
    
    Button b = new Button();
    b.Text = "Test";
    b.Location = new Point(10, 10);
    b.Size = new Size(75, 23);
    //b.Anchor = AnchorStyles.Left | AnchorStyles.Top;
    b.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
    
    this.Controls.Add(b);
    this.Show();
    

    The button just follows the change of the lower border when anchored to the bottom.

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

Sidebar

Related Questions

I have been reading up on porting ASP.NET Membership Provider into .NET 3.5 using
We have recently been faced with the problem of porting our C++ framework to
I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
In general, I have been having difficulties porting my .NET Windows Forms applications created
This may have been answered before, but I cannot find a solution that works.
I'm just porting some code over from .net to Java. I've been using the
I have been porting oracle selects, and I have been running across a lot
I have been tasked with porting a large Java codebase to the Android platform.
Have been studying the file system related classes of Adobe AIR 1.5, but so
I have been working in Visual Studio 2010, in asp.net, i am using Jquery

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.