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();
}
More Related Contents:
- How to write WinForms code that auto-scales to system font and dpi settings?
- Interaction between forms — How to change a control of a form from another form?
- Loop through Textboxes
- Cursor.Current vs. this.Cursor
- How to detect Windows shutdown or logoff
- How to handle click event in Button Column in Datagridview?
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- Combining multiple Attributes to a single Attribute – Merge Attributes
- Proper way to dispose a new Form
- How do I execute code AFTER a form has loaded?
- How do I group Windows Form radio buttons?
- Forms not responding to KeyDown events
- how to bind datatable to datagridview in c#
- DateTimePicker: pick both date and time
- Opening a “known file type” into running instance of custom app – .NET
- Displaying a collection of controls in Windows Forms
- Index of Currently Selected Row in DataGridView
- Use cookies from CookieContainer in WebBrowser
- How to set selected value from Combobox?
- WinForms Layered Controls with Background images cause tearing while scrolling
- Show Loading animation during loading data in other thread
- Determine Label Size based upon amount of text and font size in Winforms/C#
- Binding Combobox Using Dictionary as the Datasource
- Catch Application Exceptions in a Windows Forms Application
- How to inject CSS in WebBrowser control?
- C# WinForms disable DPI scaling
- Custom Color Palette in Visual Studio Color Property Editor
- Remove top and bottom padding from Text drawn on an Image
- Validating user input / Give .NET controls status OK or NOK
- How do I get a directory size (files in the directory) in C#?