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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:30:18+00:00 2026-05-26T13:30:18+00:00

My problem is : I have 2 Panels (panel1,panel2) where panel1.Size = new Size(200,

  • 0

My problem is : I have 2 Panels (panel1,panel2) where panel1.Size = new Size(200, 200); and Panel2.Size = new Size(600, 600); where both panel’s have within a CustomControl which can get Dragged and change it Possition (szbControl1 ,szbControl2) .

My Question is ,how can i set szbControl2.Location properly (proportionally)based on szbControl1.Location where szbControl1 parent is panel1 and szbControl2 parent is panel2 ,like if i move the szbControl1 at bottom also szbControl2 should be at bottom.
So far i tried this :

private void sizeAbleCTR2_LocationChanged(object sender, EventArgs e)
        {
            int smallX = (sizeAbleCTR2.Location.X * panel1.Size.Width) / 100;
            int smallY = (sizeAbleCTR2.Location.Y * panel1.Size.Height) / 100;

            int largeX = (smallX * panel2.Width) / 100;
            int largeY = (smallY * panel2.Height) / 100;

            sizeAbleCTR1.Location = new Point(largeX,largeY);
        }

like using the Percentage but it’s not working .

  • 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-26T13:30:19+00:00Added an answer on May 26, 2026 at 1:30 pm

    The code you provided does not take into account the size of the szbControls. The ratio of the (location/the differences of the sizes) should be equal.

    private void sizeAbleCTR2_LocationChanged(object sender, EventArgs e)
    {
        float srcHeightDiff = panel2.Height - sizeAbleCTR2.Height;
        float dstHeightDiff = panel1.Height - sizeAbleCTR1.Height;
    
        int locY = (int)(dstHeightDiff * (sizeAbleCTR2.Location.Y / srcHeightDiff));
    
        float srcWidthDiff = panel2.Width - sizeAbleCTR2.Width;
        float dstWidthDiff = panel1.Width - sizeAbleCTR1.Width;
    
        int locX = (float)(dstWidthDiff * (sizeAbleCTR2.Location.X / srcWidthDiff));
    
        sizeAbleCTR1.Location = new Point(locX, locY);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a strange problem here. I have a winforms panel which programatically has
I have 3 panels and I want to make drags on them. The problem
Problem: Have made a small mail program which works perfectly on my developer pc
Problem: I have an address field from an Access database which has been converted
Problem I have timestamped data, which I need to search based on the timestamp
I have a JPanel panel which contains a JTree tree . Sometimes the JTree
I have a panel where I place several mini-panels, side-by-side, with different sizes and
I have a svg file in a panel and it is displayed. The problem
I have created a new Panel called LinearLayout, and Managing the Layouting I am
I've seen that a few instances of this problem have been raised already. However,

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.