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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:03:45+00:00 2026-05-26T06:03:45+00:00

I created (using c#) a grid with border & the parent layout is another

  • 0

I created (using c#) a grid with border & the parent layout is another grid. When I try to rezise dynamically, it doesn’t give the expected behaviour.
I keep the start position (left-top) of border (with grid) fixed & only the right-bottom point is dragged to resize. In the Mouse move event, the width & height are changed depending on the current position.
1) But it always change the start point (left-top) when changing the width & height ?
2) When border get resized the child (grid) doesn’t change its dimensions accordingly ? I cann’t find any stretching method. But if border is moved, then the child grid moves with it.

    Point offsetParent;
    .....

    private void MouseMoveEvent(object sender, MouseEventArgs e)
    {
        if (bIsMouseDown)
        {
            ResizeControl(e);
            offsetParent = e.GetPosition(parentGrid); //reset offset to current                
        }
    }

    private void ResizeControl(MouseEventArgs e)
    {
        // get current point
        Point CurPosParent = e.GetPosition(parentGrid);

        // current & new position difference 
        Point diff = new Point(CurPosParent.X - offsetParent.X, CurPosParent.Y - offsetParent.Y);

        // keep start point (left-top position) of border fixed

        // adjust only width & height of border
        border1.Width += diff.X;  //changes start point (left-top position) ????
        border1.Height += diff.Y;              
    }
  • 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-26T06:03:46+00:00Added an answer on May 26, 2026 at 6:03 am

    Found out my mistake from this link Object Positioning and Layout

    Now I use a Canvas as the parent. Width & height of border & grid can be changed without changing the start point.

    Point offsetParent; 
    ..... 
    
    private void MouseMoveEvent(object sender, MouseEventArgs e) 
    { 
        if (bIsMouseDown) 
        { 
            ResizeControl(e); 
            offsetParent = e.GetPosition(parentCanvas); //reset offset to current                 
        } 
    } 
    
    private void ResizeControl(MouseEventArgs e) 
    { 
        // get current point 
        Point CurPosParent = e.GetPosition(parentCanvas); 
    
        // current & new position difference  
        Point diff = new Point(CurPosParent.X - offsetParent.X, CurPosParent.Y - offsetParent.Y); 
    
        // keep start point (left-top position) of border fixed 
    
        // adjust only width & height of border 
        border1.Width += diff.X;  
        border1.Height += diff.Y;   
        grid1.Width += diff.X;  
        grid1.Height += diff.Y;               
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a frame with a 3x3 grid of buttons using this code... JFrame
Hi friends, Am newbie for windows Development .i have created Grid With tabcontrol using
I created a grid using extjs library. First created a model: Ext.define('Option', { extend:
I am wondering if it's possible to create a grid-like layout using div's that
I'm trying to create a dynamic grid using ExtJS. The grid is built and
Given an Oracle table created using the following: CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME
My DAL is created using Linq and all is fine. However, on one page,
Guids are created using the new keyword which makes me think it's a reference
I have a solution created using visual studio 2008 named, Solution , and i
A line created using the DrawLine method of wx.DC has the onClick and onMouseOver

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.