Hey hi i am new to this field , i am working on project which is desktop application in C#,i have done this project with resolution 1024*768 but when i install the same project on testers machine for testing then position of all controls of form does not appear as like appeared on my machine...............please give me some solution for this .

On form load call this method:

private void ResizingForm()
        {
            this.Width = 1024;
            this.Height = 768;
        }

Edited 5 Years Ago by Mitja Bonca: n/a

thanks but still there is problem with controls of form........controls size does not change it remains as it is.....

Would you like that the control keeps the same ratio in any size of the form? So that the control shrinks and enlarges together with the form size?

I did some example code, how your control (in my example is this listView) moves togethe with the form.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Dec31ControlResize
{
    public partial class Form1 : Form
    {
        int cWidth, cHeight;
        int fWidth, fHeight;

        public Form1()
        {
            InitializeComponent();
            listView1.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
            cWidth = listView1.Width;
            cHeight = listView1.Height;
            fWidth = this.Width;
            fHeight = this.Height;
        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            int diffWidth = this.Width - fWidth;
            int diffHeight = this.Height-fHeight;
            diffWidth = cWidth + diffWidth;
            diffHeight = cHeight + diffHeight;
            listView1.Size = new Size(diffWidth, diffHeight);
        }
    }
}

Hope it helps,
Mitja
This article has been dead for over six months. Start a new discussion instead.