0

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 .

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
Featured Replies
  • 1
    __avd 1,826   6 Years Ago

    Take a look at - [URL="http://msdn.microsoft.com/en-us/library/ms229605(v=VS.90).aspx"]Automatic Scaling in Windows Forms[/URL] Read More

0

On form load call this method:

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

Edited by Mitja Bonca: n/a

0

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

0

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?

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.