How do I set the size of a button in centimeters?

2

I need to put a button with height and width in centimeters, where the size is maintained if it is accessed at different screen resolutions. It is possible? If so, how?

    
asked by anonymous 02.09.2015 / 18:42

1 answer

3

It is impossible to do this. There is no way to do it because there is no way to do it reliably.

Some people use a form by calculating DPI configured, but this does not reproduce the actual monitor relationship.

WPF tried to do this but the results are inaccurate and in the bottom does not deliver what it promises.

In this answer in the SO you can do the conversion if you want to insist, but do not say that I did not warn you that it does not work Right:

int CentimeterToPixel(double Centimeter) {
    double pixel = -1;
    using (Graphics g = this.CreateGraphics()) {
        pixel = Centimeter * g.DpiY / 2.54d;
    }
    return (int)pixel;
}

In general this is not even a good idea. Each person has a different need for visualization. The size in centimeters may be good for the paper, not for the screen.

    
02.09.2015 / 18:55