Click here to Skip to main content
15,314,644 members
Articles / Programming Languages / C#
Posted 20 Mar 2004


63 bookmarked

Multi-monitor programming in C#

Rate me:
Please Sign up or sign in to vote.
2.86/5 (57 votes)
20 Mar 20042 min read
How to discover and use multiple monitors.


Using multiple monitors in C# is actually a rather simple job since the monitors are combined to one big rectangle to draw on. But you can also use one single monitor if you like.

In this article, I will give a brief explanation of how to discover how many monitors the user has and how high the resolution of each monitor is.

Where do I find the right information?

The right information about monitors can be found in the Screen class of System.Windows.Forms namespace. In this class, you can find all sorts of information about how many monitors there are, and the working area of each monitor. Also, the device name can be recovered from this class.

Discovering the number of monitors

This is pretty simple. In the Screen class, you will find a property called AllScreens. This is an array of Screen objects which represent the monitors of your system. If you use the Length property of this array, you will find the number of monitors connected to your system.

The rest of the information

At each index in the array, there is a Screen class which contains the following information:

  • DeviceName
  • WorkingArea
  • Bounds
  • Primary

The DeviceName looks like this: \\.\DISPLAY1. This can be used in combination with various Windows API calls, which I won't explain here. The WorkingArea is the actual area that can be used to display graphical data, like Windows forms and other things. This area is calculated out of the Bounds minus the size of Windows taskbar. The Bounds property is the actual resolution that the monitor currently has. The Primary property is false when the screen isn't the primary one. If it is the primary screen, this property will return true.

How to discover the current screen

You can check at what screen your at, using a simple piece of code:

Screen scrn = Screen.FromControl(this);

What's in my demonstration

In the source code, you will find a small project that demonstrates all the functions explained in this article. If you compile and run the project, you can move the form from one screen to another, and the application will give the information about the screen you are at.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Netherlands Netherlands

Comments and Discussions

QuestionMultiple Monitors as Independent Displays Pin
Member 108035426-Jul-14 15:09
MemberMember 108035426-Jul-14 15:09 
GeneralMy vote of 4 Pin
Member 431244716-Nov-13 17:52
MemberMember 431244716-Nov-13 17:52 
QuestionCan anyone help me on this? Pin
caribou2us17-Jul-13 16:38
Membercaribou2us17-Jul-13 16:38 
GeneralMy vote of 1 Pin
ZejulioZ22-May-11 21:40
MemberZejulioZ22-May-11 21:40 
General[My vote of 1] Useless Pin
kingfedaikyn7-Apr-11 1:57
Memberkingfedaikyn7-Apr-11 1:57 
GeneralMy vote of 5 Pin
Avi Farah17-Nov-10 5:23
MemberAvi Farah17-Nov-10 5:23 
GeneralGreat Contribution Pin
CarlosReinoza16-Aug-10 15:41
MemberCarlosReinoza16-Aug-10 15:41 
GeneralMy vote of 1 Pin
Oreshkov Sergey15-Apr-10 21:10
MemberOreshkov Sergey15-Apr-10 21:10 
GeneralRe: My vote of 1 Pin
MasterOfCodeproject8-Dec-10 0:16
MemberMasterOfCodeproject8-Dec-10 0:16 
GeneralExcellent Pin
pbne046-Apr-10 23:21
Memberpbne046-Apr-10 23:21 
QuestionMultiple outputs for multiple monitors Pin
muralikrishnas15-Dec-08 23:34
Membermuralikrishnas15-Dec-08 23:34 
GeneralRe: Multiple outputs for multiple monitors Pin
rev4eva5-Apr-09 16:06
Memberrev4eva5-Apr-09 16:06 
GeneralDual monitor video display problem Pin
Member 46937877-Aug-08 1:45
MemberMember 46937877-Aug-08 1:45 
GeneralRe: Dual monitor video display problem Pin
Ashley Staggs2-Sep-08 10:07
MemberAshley Staggs2-Sep-08 10:07 
QuestionActive or not active? Pin
Lofote18-Aug-05 3:07
MemberLofote18-Aug-05 3:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.