Creating Rectangular in C#
In this article we will create a rectangular using graphics objects.
Introduction
Graphics object is very interested and easy to create in window form. We have now to create a rectangular in C# by the graphics object. There are very small coding that is giving below.
Example
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;
namespace WindowsFormsApplication14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics graphicsObj;
graphicsObj = this.CreateGraphics();
Pen myPen = new Pen(System.Drawing.Color.Blue, 5);
Rectangle myRectangle = new Rectangle(40, 40, 200, 150);
graphicsObj.DrawRectangle(myPen, myRectangle);
}
}
}
Output