views:

41

answers:

1

I've tried this example directly from MSDN:

Dim Screens() As System.Windows.Forms.Screens

and I can't find a way to get a reference to the Screen. I've checked my references and they seem fine but I may have missed something. Anyone experience this or know of a bug?

EDIT 0: It helps if you're using the correct project type. In WPF, it's SystemParameters. Thanks all.

+1  A: 

I'm fairly sure you actually want

Dim Screens() As System.Windows.Forms.Screen

(no s at the end), as there isn't a Screens type. The above line declares Screens as an array of Screen objects - now you can do

Screens = System.Windows.Forms.Screen.AllScreens

and do whatever it is you want to do with each Screen.

edit not sure what reference problem you are still getting. From scratch, I start a new Windows Forms project, replace the code-behind in Form1 with this:

Public Class Form1

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim Screens() As System.Windows.Forms.Screen
        Screens = System.Windows.Forms.Screen.AllScreens

        For Each s As Screen In Screens
            MessageBox.Show(s.DeviceName)
        Next

    End Sub
End Class

and it runs and does what I expect. This is VS2005 (not Express) but I can't imagine that would make a difference.

AakashM
Thanks AakashM, but no joy. I've tried several variations and I can't find a reference.
Brad
I tried the same thing from scratch and still no luck... I'm going to re-install. It can't anything else?!?
Brad
@Brad. Is it definitely a Windows Forms project?
MarkJ
I am BRAD, lord of the idiots! Thanks Mark. *^%$#^$#)*)(*^
Brad