Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Discover the top 5 tips for understanding .NET Interop
Search :       Advanced Search »
Home » C# Language » How to change screen resolution in C#

How to change screen resolution in C#

All programmers are facing common problem is how to change screen Resolution dynamically. In .Net 2005 it's very easy to change the screen resolution. Here I will explain you how can we get the Screen resolution and how we will change the resolution at dynamically and while unloading the page it will come as it was before. In dot net we can access the values of user's screen resolution through the Resolution class. It also affects all running (and minimized) programs.

Page Views : 109708
Downloads : 3211
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
Resolution.zip
 
 
DevExpress Free UI Controls
Become a Sponsor
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


Introduction

It is a sample program It will demonstrate how to change resolution at runtime.

All programmers are facing common problem is how to change screen Resolution dynamically. In .Net 2005 it's very easy to change the screen resolution. Here I will explain you how can we get the screen resolution and how we will change the resolution dynamically and while unloading the page it will come as it was before. In .NET we can access the values of user's screen resolution through the Resolution class. It also affects all running (and minimized) programs.

Page_Load Code

Screen Srn = Screen.PrimaryScreen;

tempHeight = Srn.Bounds.Width;

tempWidth = Srn.Bounds.Height;

Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type=\"text/javascript\">alert('" + "Your Current Resolution  is = " + tempHeight + " * " + tempWidth + "');</script>");

//if you want Automatically Change res.at page load. please uncomment this code.

 

if (tempHeight == 600)//if the system is 800*600 Res.then change to

{

FixHeight = 768;

FixWidth = 1024;

Resolution.CResolution ChangeRes = new Resolution.CResolution(FixHeight, FixWidth);

} 

Change Resoultion 

switch (cboRes.SelectedValue.ToString())

{

    case "800*600":

        FixHeight = 800;

        FixWidth = 600;

        Resolution.CResolution ChangeRes600 = new Resolution.CResolution(FixHeight, FixWidth);

        break;

 

    case "1024*768":

        FixHeight = 1024;

        FixWidth = 768;

        Resolution.CResolution ChangeRes768 = new Resolution.CResolution(FixHeight, FixWidth);

        break;

    case "1280*1024":

        FixHeight = 1280;

        FixWidth = 1024;

        Resolution.CResolution ChangeRes1024 = new Resolution.CResolution(FixHeight, FixWidth);

        break;

}

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Joshy George
Joshy George , has over 5 years in Microsoft technologies. Certified Microsoft Professional with Master Degree in Computers. Working with Infogenie ITAS Pvt.Ltd,Infopark,Kochin,India, as a Sr.Software Engineer and have good experience in C#,ASP.net ,VB, ASP, SQL Server, smart card application,Tapii,Com ctrls.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
Become a Sponsor
 Comments
Screen Res Change by Brian On October 23, 2006
I
Reply | Email | Modify 
Screen Res Change by Brian On October 23, 2006
I was
Reply | Email | Modify 
Screen Res Change by Brian On October 23, 2006

I was able to run the screen res function once or twice and it worked and then after that I would get this error

 

MessageBox.Show("Unable to process your request");

MessageBox.Show("Description: Unable To Process Your Request. Sorry For This Inconvenience.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

 

What might I be missing

Reply | Email | Modify 
Re: Screen Res Change by Sachin On October 25, 2007
Hi Can U get how to Change the client side resolution so please tell me
Reply | Email | Modify 
Screen Class by Pankaj On November 1, 2006

 

Can u please tell me in which namespace screen class is?

 

Pankaj Gupta

Reply | Email | Modify 
please reply earlier by asad On November 12, 2006

hey sir,

i am student of graduate program in first semister I have to submit my presentation on "C graphics" at 22nd of this month. Can you help me for making presentation? Please reply me earlier.....My ID is asad_uk2003@hotmail.com

Reply | Email | Modify 
Dynamic tool tip text by Ranjan On December 28, 2006

Sir,

I am ranjan .1) How can we create dynamic too tip text in VB.Net.So that

whatever content is in the textbox or any other control when i take the mouse over the control I can see all the content of that control which is unvisible to me.

2) ur code on screen resolution is fine but if u can send it in VB.Net source code.

My email id is :itranjan@yahoo.com cellno.09891550294

It'S urgent pls send it as soon as possible till tomorrow.

                                    Thanking you.

Reply | Email | Modify 
doubt by mohan On May 31, 2007
Hi Sir, now i am working in software programmer. how to change the screen resolution in vb.net? send the answere to my email id is m.mohanraj.pro@gmail.com
Reply | Email | Modify 
doubt by mohan On May 31, 2007

Hi Sir, now i am working in software programmer. how to change the screen resolution in vb.net? send the answere to my email id is m.mohanraj.pro@gmail.com

 

by mohan raj.

 

===================> Replay me<========================

Reply | Email | Modify 
Screen Res Change by siddique On December 18, 2007
Its great dear. Well done man. I like it. Thanks once again of you
Reply | Email | Modify 
How to change screen resolution in C# by Lokesh On December 28, 2007
hello sir in which namespace resolution class is found. i am having problem in locating this class
Reply | Email | Modify 
Que by vinayak On February 24, 2008
hello sir my que i , in C# how to compare two word (.doc) files? please reply me sir
Reply | Email | Modify 
depends of OS Version by Marcela On September 25, 2008
Hi.... I have already test this funcion "Screen.PrimaryScreen;" But it return diferent values where i exceute my web page on Windwos Server and on Windows Vista Why? Why if a change my resolution in Vista... this value is always the same? Tnk's
Reply | Email | Modify 
dss by hossam On December 20, 2008
thanks
Reply | Email | Modify 
Resolution problem - Windows application by karthizen On January 28, 2009
I am a beginner to c# & right now doing a windows application, I guess the above example is for web application. Can anyone guide me in changing the resolution while working in windows application? Regards, karthik
Reply | Email | Modify 
Re: Resolution problem - Windows application by Hardik On July 1, 2009
Hi,

              I was try so many times to change resolution. But this is not possilble. i m trying to solve this problem.If you find somthing good pls send me as soon as possible. I need someone help. haddyamd@gmail.com
Reply | Email | Modify 
Not workin by kartik On January 30, 2009
This one is not working shows the exception....
Reply | Email | Modify 
C# Resolution by Hardik On July 1, 2009
Hi,

            Is it possible in windows based application ? I want to change resolution at runtime.Please send me code. i was try but this is not possible.haddyamd@gmail.com   
Reply | Email | Modify 
re: by Bhavna On August 10, 2009
hello sir,
        your code is working very good.
thank you.
Garasia Bhavna.
Reply | Email | Modify 
not working in c#.net windows application by selvaraj On December 16, 2009
Hi,

your coding is working correctly. i am using this code in c#.net windows application.
But cannot able to change screen resolution. I am getting message "

Description: Failed To Change The Resolution". how to solve this problem. pls help me.

Selvaraj.S


Reply | Email | Modify 
got error Unable to process your request by raja On December 23, 2009

HI George,

i got an error message says that

"Unable to process your request"

can u suggest me???

 

Reply | Email | Modify 
Reply to Unable to process your request by raja On December 24, 2009
This is hosting probelm..

if u r hosting in asp.net management server it is working fine..
But not working in IIS..

I am trying to find solution for this..
Hope Soon...
Reply | Email | Modify 
can you please tell me the namespace used for Resolution class in c#.net by chandruswami On June 10, 2010
can you please tell me the namespace used for Resolution class in c#.net
Reply | Email | Modify 
How to change web site according to screen resolution in mobile. by richa On June 24, 2010
How to change web site according to screen resolution in mobile.
please give me a answer in richa26rd@gmail.com.................
its argent for me.
 
Please send the code. Its a very argent work  for me......................

thanksssss
Reply | Email | Modify 
This is just a fake by dussel On December 2, 2010
In fact he is using windows apis to change the resolution. There is no class "Resolution" in .Net. For all who want to get the code but don't want to register:
It's just a wrapper class called cResolution in an userdefined namespace Resolution that makes use of win32 api calls "EnumDisplaySettings" and "ChangeDisplaySettings". There are tons of examples for .net using this api, so no need to register. The opening paragraph "In .Net 2005 it's very easy to change the screen resolution" does only apply with an additional "if you already have a class which handles changing the resolution". Sorry man, but this is ridiculous.
Reply | Email | Modify 
jus to say thnx by zara On March 18, 2011
hi i m making d website in wich i need dis resolution coding thnx alot
Reply | Email | Modify 
Nevron Chart
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.