16 August 2012

Screen Resolution Program in C#.net

Simply says, Display Resolution or Monitor Resolution. I give the demo for Screen Resolution. It's a very simple and easily understandable How to maximize a form without using Maximize Button? 
Use this Code.
In the Namespace
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//Form Loading
private void Form1_Load(object sender, EventArgs e)
// To get Current Screen Resoltion
int tempwidth = Screen.PrimaryScreen.Bounds.Width;
int tempHeight = Screen.PrimaryScreen.Bounds.Height;
int tempX = Screen.PrimaryScreen.Bounds.X;
int tempY = Screen.PrimaryScreen.Bounds.Y;
this.Width = tempwidth;
this.Height = tempHeight-15;
this.Location = new Point(tempX, tempY);
dataGridView1.Width = tempwidth;
dataGridView1.Height = tempHeight;
int tempcol = tempwidth / 5;
dataGridView1.Columns[0].Width = tempcol;
dataGridView1.Columns[1].Width = tempcol;
dataGridView1.Columns[2].Width = tempcol;
dataGridView1.Columns[3].Width = tempcol;
dataGridView1.Columns[4].Width = tempcol;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

No comments: