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

  • Home
  • SEARCH
  • 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 6220385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:56:51+00:00 2026-05-24T07:56:51+00:00

this is my first post here so I hope I provide all the right

  • 0

this is my first post here so I hope I provide all the right information.

I am currently developing a simple menu application that has a control array of buttons (using the work around for control arrays suggested by MSDN) and I am having a hard time with re-sizing the form and centering the buttons. These buttons are created at compile time (with parameters from an INI file) and my current centering algorithm seems to slightly set them to the right. I am using the “button.location = new Point(…,…)” method but after reading about this it says the values locate the buttons left upper corner rather than center, thus accounting for the slight offset to the right.

My two questions are this:

How can I perfectly center these buttons at compile time? I have tried accounting for the difference by subtracting half of the button’s width but the button width and point properties seem to be incompatible and the button gets heavily offset.

And… my other goal for re-sizing the menu is to have the buttons perfectly expand and contract when being re-sized. It seems as though anchoring is ineffective when the buttons are created dynamically so I have been forced to write ratio algorithms… Is there a way to get anchoring to work?

Here’s what I have in the load up :

 MyControlArray(i).Location = New Point(CInt(((Width - ButtonWidth) / 2) +_
(ButtonWidth / 2)), CInt((Height - MyControlArray(i).Height) / 2))

I have already tried:

New Point(CInt(((Width - ButtonWidth) / 2)), CInt((Height - MyControlArray(i).Height)_
/ 2))
  • 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-24T07:56:52+00:00Added an answer on May 24, 2026 at 7:56 am

    That’s because you use the wrong variables, Width and Height include the borders and caption. You should use the ClientSize property instead. Like this:

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)
        Dim btn = New Button()
        Controls.Add(btn)
        btn.Location = New Point((ClientSize.Width - btn.Width) \ 2, _
                                 (ClientSize.Height - btn.Height) \ 2)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My first post here, so i hope this is the right area. I am
Hi this is my first post here hope you all are well. So Im
This is my first time here so I hope I post this question at
this is my first post so I hope I am posting to the right
Usless Background Info Hello, all. This is my first post here, but I often
This is my first post here and I wanted to get some input from
Well, this is my first post here and really enjoying the site. I have
this is my first question here so I hope I can articulate it well
My first post on this site with huge hope:: I am trying to understand
this is my first time to post here. I have a problem on my

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.