I'm trying to build a Windows Forms application using C#.
How do I get the DPI in .NET?
I've read before that there is DPIX and DPIY, which can be used in .NET to get the current DPI.
Is that correct?
Thanks all.
Use an instance of the Graphics
class. You get this using the following within your form (could be in form's Load
event handler):
float dx, dy;
Graphics g = this.CreateGraphics();
try
{
dx = g.DpiX;
dy = g.DpiY;
}
finally
{
g.Dispose();
}