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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:28:07+00:00 2026-06-07T13:28:07+00:00

I’ve just finished building a portion of a program which deals with a UI

  • 0

I’ve just finished building a portion of a program which deals with a UI in a table layout panel. This has worked so far but i’ve noticed that, before i could try my controls (functionality i added) at runtime around the form, but now it is in cells, they can’t be moved outside of their container cell. HOWEVER, this is great and exactly what i needed, but im finding that the controls (for example a button) will be correctly contained in the cell on the left, and top boundaries of the cell, but the bottom and right boundaries allow the control to disappear off of it. Heres some screenshots to demonstrate:

enter image description here

Here we see that the button control cannot move past the top and left bounds of the cell.

enter image description here

However here it seems to be able to move past the bottom and right bounds of the cell.

Looking back at how i allow my controls to move, i came across a section where i had set up some variables, shown below:

public static void MouseMove(object sender, MouseEventArgs e)
         {
             Control control = sender as Control;
             Control container = sender as Control;
             if (control != null)
             {
                 if (Dragging)
                 {
                     if (direction != Direction.Vertical)
                     {
                         container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
                     }
                     if (direction != Direction.Horizontal)
                     {
                         container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
                     }
                 }
             }
         }

I figured here i’m not setting a bottom and right container bounds, which would make sense, however upon exploring the intelisense, i can’t seem to get container.right and container.bottom as they come with the following tooltip:

"gets the distance, in pixels, between the right edge of the control, and the left edge of it's container's client area"

and the bottom does the same, only for the bottom of the control and top of the container area.

Is there away around this? perhaps an option somewhere which connects the bottom of the control to the bottom bound of the cell, and the same for the right?

edit 1: alternatively perhaps i need to alter my mousemove event to handle collision better, so if anyone has any ideas on this too, that’d be great, i’ve not really looked at much collision detection before, especially in 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-06-07T13:28:10+00:00Added an answer on June 7, 2026 at 1:28 pm

    Control.right is a read only property. Try setting

    if (direction != Direction.Vertical)
    {
        container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
        container.Left = Math.Min(container.Left, container.Parent.Width - container.Width;
    }
    if (direction != Direction.Horizontal)
    {
        container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
        container.Top = Math.Min(container.Top, container.Parent.Height - container.Height;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has

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.