1

I need the screen DPI so i can adjust my program accordingly.

So my question is How to detect the screen DPI using VB.NET?

Tadumc421
  • 149
  • 2
  • 4
  • 12
  • [Do a Me.CreateGraphics() in the form load, there's a property DpiX and DpiY](https://stackoverflow.com/questions/6844161/how-to-get-dpi-in-c-sharp-net) – the_lotus Jun 12 '18 at 13:36
  • WPF or WinForms? [For WPF, see here](https://stackoverflow.com/questions/1918877/how-can-i-get-the-dpi-in-wpf) – MatSnow Jun 12 '18 at 13:42
  • 1
    Possible duplicate of [How to get DPI in C# .NET?](https://stackoverflow.com/questions/6844161/how-to-get-dpi-in-c-sharp-net) – braX Jun 12 '18 at 13:44

1 Answers1

2

try this:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim g As Graphics = Me.CreateGraphics()
    MessageBox.Show("ScreenWidth:" & Screen.PrimaryScreen.Bounds.Width & " ScreenHeight:" & Screen.PrimaryScreen.Bounds.Height & vbCrLf & " DpiX:" & g.DpiX & " DpiY:" & g.DpiY)
End Sub