draw rectangle in millimeters doesnt show accurate width

Posted by user338081 on Stack Overflow See other posts from Stack Overflow or by user338081
Published on 2010-05-11T09:21:39Z Indexed on 2010/05/11 9:34 UTC
Read the original article Hit count: 197

Filed under:

I am drawing a rectangle in millimeter on a panel using the following code in c# by entering the width and length in mm at runtime. however the resultant rectangle drawn varies in size in different monitors. I want the rectangle to appear same size irrespective of the running the app in any monitor. Can any1 help me?. currently the width for 10mm measures 12mm and length for 10mm shows 11mm using a scale. I tested the appn on different monitors, there again it shows different length. Is ther anyway that i can show it to be of same width and length?

void panel1_Paint(object sender, PaintEventArgs e)
        {

            SolidBrush ygBrush = new SolidBrush(Color.YellowGreen);
            g = panel1.CreateGraphics();
            g.PageUnit = GraphicsUnit.Millimeter;

            int w = Int32.Parse(textBox1.Text.ToString());
            int h = Int32.Parse(textBox2.Text.ToString());

            rct = new Rectangle(94, 27, w, h);
            g.FillRectangle(ygBrush, rct);


        }

© Stack Overflow or respective owner

Related posts about c#