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 .

Recommended Answers

All 6 Replies

On form load call this method:

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

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?

Yes Exactly same i want.......

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.