0% found this document useful (0 votes)
39 views53 pages

67 C# Record

Uploaded by

Snehith Premraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views53 pages

67 C# Record

Uploaded by

Snehith Premraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 53

18CSA 307 C# and .

Net Framework LAB Record


Bachelor of Computer Application
December 2022

Submitted By
Name: Snehith Premraj
Roll Number: AM.SC.U3CSC20067

Index
Sl. No Problem Statement Page

1 | Page
Number
1 Display a progressive clock to show the current hour, minute and second. 3
2 Using Timer Control and Label, create a .NET form to display the following. 8
3 Create a Windows form application to create an HTML line of Body tag using the GUI 12
shown below.

4 Create a dynamic calculator using windows form controls which will do all type of 22
arithmetical calculations

5 Create a common registration form(name, address, phone number, gender, email id 33


etc) and save the data to a database.

6 Create an address book application which will have all the facility to ✓ Store the 40
address of a person. (execute insert query) ✓ Update the address of a person with
mobile phone ✓ Delete address of a person ✓ Display address of a person ( search by
name, search by mobile number). Create your data base accordingly with the details
name , house name, mobile number, house number, pin code, location, district

2 | Page
1.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void timer1_Tick(object sender, EventArgs e)


{
progressBar1.Value = DateTime.Now.Hour;
progressBar2.Value = DateTime.Now.Minute;
progressBar3.Value = DateTime.Now.Second;
label4.Text = DateTime.Now.Hour.ToString();
label5.Text = DateTime.Now.Minute.ToString();
label6.Text = DateTime.Now.Second.ToString();
}

private void button1_Click(object sender, EventArgs e)


{
Close();
}
}
}

Form1.Designer.cs

namespace _1
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>

3 | Page
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.progressBar2 = new System.Windows.Forms.ProgressBar();
this.progressBar3 = new System.Windows.Forms.ProgressBar();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(65, 66);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 17);
this.label1.TabIndex = 0;
this.label1.Text = "Hour";
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(110, 66);
this.progressBar1.Maximum = 24;
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(351, 23);
this.progressBar1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(54, 130);
this.label2.Name = "label2";

4 | Page
this.label2.Size = new System.Drawing.Size(50, 17);
this.label2.TabIndex = 2;
this.label2.Text = "Minute";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(48, 193);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 17);
this.label3.TabIndex = 3;
this.label3.Text = "Second";
//
// progressBar2
//
this.progressBar2.Location = new System.Drawing.Point(110, 130);
this.progressBar2.Maximum = 60;
this.progressBar2.Name = "progressBar2";
this.progressBar2.Size = new System.Drawing.Size(351, 23);
this.progressBar2.TabIndex = 4;
//
// progressBar3
//
this.progressBar3.Location = new System.Drawing.Point(110, 187);
this.progressBar3.Maximum = 60;
this.progressBar3.Name = "progressBar3";
this.progressBar3.Size = new System.Drawing.Size(351, 23);
this.progressBar3.TabIndex = 5;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(468, 71);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(46, 17);
this.label4.TabIndex = 6;
this.label4.Text = "label4";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(467, 136);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(46, 17);
this.label5.TabIndex = 7;
this.label5.Text = "label5";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(467, 193);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(46, 17);

5 | Page
this.label6.TabIndex = 8;
this.label6.Text = "label6";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(467, 31);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(39, 17);
this.label7.TabIndex = 9;
this.label7.Text = "Time";
//
// button1
//
this.button1.Location = new System.Drawing.Point(431, 237);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 10;
this.button1.Text = "Close";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(593, 272);
this.Controls.Add(this.button1);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.progressBar3);
this.Controls.Add(this.progressBar2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

#endregion

private System.Windows.Forms.Label label1;


private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ProgressBar progressBar2;
private System.Windows.Forms.ProgressBar progressBar3;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;

6 | Page
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button button1;
}
}

Form1.cs [Design]

Output

7 | Page
2.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;

namespace _2
{
public partial class Form1 : Form
{
private long comptime;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
comptime = Environment.TickCount;
}

private void timer1_Tick(object sender, EventArgs e)


{
long currTime = Environment.TickCount;
long diff = currTime - comptime;
long ComputerHours, ComputerMinutes, ComputerSeconds;
long AppHours, AppMinutes, AppSeconds;

ComputerHours = (currTime / (3600 * 999) % 24);


ComputerMinutes = (currTime / (60 * 999) % 60);
ComputerSeconds = (currTime / (999) % 60);

AppHours = (diff / (3600 * 999) % 24);


AppMinutes = (diff / (60 * 999) % 60);
AppSeconds = (diff / (999) % 60);

label2.Text = String.Format("{0} Hours,{1} Minutes,{2} Seconds",


ComputerHours, ComputerMinutes, ComputerSeconds);
label4.Text = String.Format("{0} Hours,{1} Minutes,{2} Seconds",
AppHours, AppMinutes, AppSeconds);
}

private void button1_Click(object sender, EventArgs e)


{
Close();
}
}
}

8 | Page
Form1.Designer.cs

namespace _2
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(84, 84);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(207, 17);
this.label1.TabIndex = 0;
this.label1.Text = "This computer has been ON for";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(297, 84);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(46, 17);

9 | Page
this.label2.TabIndex = 1;
this.label2.Text = "label2";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(84, 124);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(243, 17);
this.label3.TabIndex = 2;
this.label3.Text = "This application has been running for";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(333, 124);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(46, 17);
this.label4.TabIndex = 3;
this.label4.Text = "label4";
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// button1
//
this.button1.Location = new System.Drawing.Point(304, 162);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Close";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(596, 202);
this.Controls.Add(this.button1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

#endregion

private System.Windows.Forms.Label label1;


private System.Windows.Forms.Label label2;

10 | Page
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Button button1;
}
}

Form1.cs [Design]

Output

11 | Page
3.
form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _3
{
public partial class Form1 : Form
{
public String bgColor,linkColor, txtColor, activeColor, visitedColor;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
Close();
}

private void txtButton_CheckedChanged(object sender, EventArgs e)


{
txtColor = txtText.Text;

private void linkButton_CheckedChanged(object sender, EventArgs e)


{
linkColor = linkText.Text;
}

private void activeButton_CheckedChanged(object sender, EventArgs e)


{
activeColor = activeText.Text;
}

private void visitedButton_CheckedChanged(object sender, EventArgs e)


{
visitedColor = visitedText.Text;
}

private void button2_Click(object sender, EventArgs e)


{
textBox9.Copy();
}

private void Form1_Load(object sender, EventArgs e)


{
textBox9.Text = "Hello";

12 | Page
}

private void bgButton_CheckedChanged(object sender, EventArgs e)


{
bgColor = bgText.Text;
}
}
}

Form1.Designer.cs

1. namespace _3
2. {
3.     partial class Form1
4.     {
5.         /// <summary>
6.         /// Required designer variable.
7.         /// </summary>
8.         private System.ComponentModel.IContainer components = null;
9.  
10.         /// <summary>
11.         /// Clean up any resources being used.
12.         /// </summary>
13.         /// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
14.         protected override void Dispose(bool disposing)
15.         {
16.             if (disposing && (components != null))
17.             {
18.                 components.Dispose();
19.             }
20.             base.Dispose(disposing);
21.         }
22.  
23.         #region Windows Form Designer generated code
24.  
25.         /// <summary>
26.         /// Required method for Designer support - do not modify
27.         /// the contents of this method with the code editor.
28.         /// </summary>
29.         private void InitializeComponent()
30.         {
31.             this.groupBox1 = new System.Windows.Forms.GroupBox();
32.             this.visitedText = new System.Windows.Forms.TextBox();
33.             this.activeText = new System.Windows.Forms.TextBox();
34.             this.linkText = new System.Windows.Forms.TextBox();
35.             this.txtText = new System.Windows.Forms.TextBox();
36.             this.bgText = new System.Windows.Forms.TextBox();
37.             this.visitedButton = new System.Windows.Forms.RadioButton();
38.             this.activeButton = new System.Windows.Forms.RadioButton();
39.             this.linkButton = new System.Windows.Forms.RadioButton();
40.             this.txtButton = new System.Windows.Forms.RadioButton();
41.             this.bgButton = new System.Windows.Forms.RadioButton();
42.             this.panel1 = new System.Windows.Forms.Panel();
43.             this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
44.             this.vScrollBar2 = new System.Windows.Forms.VScrollBar();
45.             this.vScrollBar3 = new System.Windows.Forms.VScrollBar();
46.             this.groupBox2 = new System.Windows.Forms.GroupBox();
47.             this.textBox8 = new System.Windows.Forms.TextBox();

13 | Page
48.             this.textBox7 = new System.Windows.Forms.TextBox();
49.             this.label3 = new System.Windows.Forms.Label();
50.             this.label2 = new System.Windows.Forms.Label();
51.             this.label1 = new System.Windows.Forms.Label();
52.             this.textBox6 = new System.Windows.Forms.TextBox();
53.             this.panel2 = new System.Windows.Forms.Panel();
54.             this.button1 = new System.Windows.Forms.Button();
55.             this.button2 = new System.Windows.Forms.Button();
56.             this.textBox9 = new System.Windows.Forms.TextBox();
57.             this.label4 = new System.Windows.Forms.Label();
58.             this.label5 = new System.Windows.Forms.Label();
59.             this.label6 = new System.Windows.Forms.Label();
60.             this.label7 = new System.Windows.Forms.Label();
61.             this.label8 = new System.Windows.Forms.Label();
62.             this.groupBox1.SuspendLayout();
63.             this.groupBox2.SuspendLayout();
64.             this.panel2.SuspendLayout();
65.             this.SuspendLayout();
66.             //
67.             // groupBox1
68.             //
69.             this.groupBox1.Controls.Add(this.visitedText);
70.             this.groupBox1.Controls.Add(this.activeText);
71.             this.groupBox1.Controls.Add(this.linkText);
72.             this.groupBox1.Controls.Add(this.txtText);
73.             this.groupBox1.Controls.Add(this.bgText);
74.             this.groupBox1.Controls.Add(this.visitedButton);
75.             this.groupBox1.Controls.Add(this.activeButton);
76.             this.groupBox1.Controls.Add(this.linkButton);
77.             this.groupBox1.Controls.Add(this.txtButton);
78.             this.groupBox1.Controls.Add(this.bgButton);
79.             this.groupBox1.Location = new System.Drawing.Point(38, 34);
80.             this.groupBox1.Name = "groupBox1";
81.             this.groupBox1.Size = new System.Drawing.Size(246, 174);
82.             this.groupBox1.TabIndex = 0;
83.             this.groupBox1.TabStop = false;
84.             this.groupBox1.Text = "Body Attributes";
85.             //
86.             // visitedText
87.             //
88.             this.visitedText.Location = new System.Drawing.Point(118, 142);
89.             this.visitedText.Name = "visitedText";
90.             this.visitedText.Size = new System.Drawing.Size(100, 22);
91.             this.visitedText.TabIndex = 6;
92.             //
93.             // activeText
94.             //
95.             this.activeText.Location = new System.Drawing.Point(118, 114);
96.             this.activeText.Name = "activeText";
97.             this.activeText.Size = new System.Drawing.Size(100, 22);
98.             this.activeText.TabIndex = 6;
99.             //
100.             // linkText
101.             //
102.             this.linkText.Location = new System.Drawing.Point(118, 86);
103.             this.linkText.Name = "linkText";
104.             this.linkText.Size = new System.Drawing.Size(100, 22);
105.             this.linkText.TabIndex = 6;
106.             //
107.             // txtText
108.             //

14 | Page
109.             this.txtText.Location = new System.Drawing.Point(118, 58);
110.             this.txtText.Name = "txtText";
111.             this.txtText.Size = new System.Drawing.Size(100, 22);
112.             this.txtText.TabIndex = 6;
113.             //
114.             // bgText
115.             //
116.             this.bgText.Location = new System.Drawing.Point(118, 31);
117.             this.bgText.Name = "bgText";
118.             this.bgText.Size = new System.Drawing.Size(100, 22);
119.             this.bgText.TabIndex = 5;
120.             //
121.             // visitedButton
122.             //
123.             this.visitedButton.AutoSize = true;
124.             this.visitedButton.Location = new System.Drawing.Point(6, 140);
125.             this.visitedButton.Name = "visitedButton";
126.             this.visitedButton.Size = new System.Drawing.Size(101, 21);
127.             this.visitedButton.TabIndex = 4;
128.             this.visitedButton.TabStop = true;
129.             this.visitedButton.Text = "Visited Link";
130.             this.visitedButton.UseVisualStyleBackColor = true;
131.             this.visitedButton.CheckedChanged += new
System.EventHandler(this.visitedButton_CheckedChanged);
132.             //
133.             // activeButton
134.             //
135.             this.activeButton.AutoSize = true;
136.             this.activeButton.Location = new System.Drawing.Point(6, 113);
137.             this.activeButton.Name = "activeButton";
138.             this.activeButton.Size = new System.Drawing.Size(97, 21);
139.             this.activeButton.TabIndex = 3;
140.             this.activeButton.TabStop = true;
141.             this.activeButton.Text = "Active Link";
142.             this.activeButton.UseVisualStyleBackColor = true;
143.             this.activeButton.CheckedChanged += new
System.EventHandler(this.activeButton_CheckedChanged);
144.             //
145.             // linkButton
146.             //
147.             this.linkButton.AutoSize = true;
148.             this.linkButton.Location = new System.Drawing.Point(6, 86);
149.             this.linkButton.Name = "linkButton";
150.             this.linkButton.Size = new System.Drawing.Size(55, 21);
151.             this.linkButton.TabIndex = 2;
152.             this.linkButton.TabStop = true;
153.             this.linkButton.Text = "Link";
154.             this.linkButton.UseVisualStyleBackColor = true;
155.             this.linkButton.CheckedChanged += new
System.EventHandler(this.linkButton_CheckedChanged);
156.             //
157.             // txtButton
158.             //
159.             this.txtButton.AutoSize = true;
160.             this.txtButton.Location = new System.Drawing.Point(7, 59);
161.             this.txtButton.Name = "txtButton";
162.             this.txtButton.Size = new System.Drawing.Size(56, 21);
163.             this.txtButton.TabIndex = 1;
164.             this.txtButton.TabStop = true;
165.             this.txtButton.Text = "Text";
166.             this.txtButton.UseVisualStyleBackColor = true;

15 | Page
167.             this.txtButton.CheckedChanged += new
System.EventHandler(this.txtButton_CheckedChanged);
168.             //
169.             // bgButton
170.             //
171.             this.bgButton.AutoSize = true;
172.             this.bgButton.Location = new System.Drawing.Point(6, 31);
173.             this.bgButton.Name = "bgButton";
174.             this.bgButton.Size = new System.Drawing.Size(105, 21);
175.             this.bgButton.TabIndex = 0;
176.             this.bgButton.TabStop = true;
177.             this.bgButton.Text = "Background";
178.             this.bgButton.UseVisualStyleBackColor = true;
179.             this.bgButton.CheckedChanged += new
System.EventHandler(this.bgButton_CheckedChanged);
180.             //
181.             // panel1
182.             //
183.             this.panel1.Location = new System.Drawing.Point(290, 34);
184.             this.panel1.Name = "panel1";
185.             this.panel1.Size = new System.Drawing.Size(229, 174);
186.             this.panel1.TabIndex = 1;
187.             //
188.             // vScrollBar1
189.             //
190.             this.vScrollBar1.Location = new System.Drawing.Point(546, 34);
191.             this.vScrollBar1.Name = "vScrollBar1";
192.             this.vScrollBar1.Size = new System.Drawing.Size(24, 174);
193.             this.vScrollBar1.TabIndex = 2;
194.             //
195.             // vScrollBar2
196.             //
197.             this.vScrollBar2.Location = new System.Drawing.Point(582, 34);
198.             this.vScrollBar2.Name = "vScrollBar2";
199.             this.vScrollBar2.Size = new System.Drawing.Size(24, 174);
200.             this.vScrollBar2.TabIndex = 3;
201.             //
202.             // vScrollBar3
203.             //
204.             this.vScrollBar3.Location = new System.Drawing.Point(621, 34);
205.             this.vScrollBar3.Name = "vScrollBar3";
206.             this.vScrollBar3.Size = new System.Drawing.Size(24, 174);
207.             this.vScrollBar3.TabIndex = 4;
208.             //
209.             // groupBox2
210.             //
211.             this.groupBox2.Controls.Add(this.textBox8);
212.             this.groupBox2.Controls.Add(this.textBox7);
213.             this.groupBox2.Controls.Add(this.label3);
214.             this.groupBox2.Controls.Add(this.label2);
215.             this.groupBox2.Controls.Add(this.label1);
216.             this.groupBox2.Controls.Add(this.textBox6);
217.             this.groupBox2.Location = new System.Drawing.Point(319, 247);
218.             this.groupBox2.Name = "groupBox2";
219.             this.groupBox2.Size = new System.Drawing.Size(177, 131);
220.             this.groupBox2.TabIndex = 5;
221.             this.groupBox2.TabStop = false;
222.             this.groupBox2.Text = "Color Values";
223.             //
224.             // textBox8
225.             //

16 | Page
226.             this.textBox8.Location = new System.Drawing.Point(63, 56);
227.             this.textBox8.Name = "textBox8";
228.             this.textBox8.Size = new System.Drawing.Size(100, 22);
229.             this.textBox8.TabIndex = 5;
230.             //
231.             // textBox7
232.             //
233.             this.textBox7.Location = new System.Drawing.Point(63, 88);
234.             this.textBox7.Name = "textBox7";
235.             this.textBox7.Size = new System.Drawing.Size(100, 22);
236.             this.textBox7.TabIndex = 4;
237.             //
238.             // label3
239.             //
240.             this.label3.AutoSize = true;
241.             this.label3.Location = new System.Drawing.Point(9, 93);
242.             this.label3.Name = "label3";
243.             this.label3.Size = new System.Drawing.Size(48, 17);
244.             this.label3.TabIndex = 3;
245.             this.label3.Text = "Green";
246.             //
247.             // label2
248.             //
249.             this.label2.AutoSize = true;
250.             this.label2.Location = new System.Drawing.Point(7, 59);
251.             this.label2.Name = "label2";
252.             this.label2.Size = new System.Drawing.Size(36, 17);
253.             this.label2.TabIndex = 2;
254.             this.label2.Text = "Blue";
255.             //
256.             // label1
257.             //
258.             this.label1.AutoSize = true;
259.             this.label1.Location = new System.Drawing.Point(7, 22);
260.             this.label1.Name = "label1";
261.             this.label1.Size = new System.Drawing.Size(34, 17);
262.             this.label1.TabIndex = 1;
263.             this.label1.Text = "Red";
264.             //
265.             // textBox6
266.             //
267.             this.textBox6.Location = new System.Drawing.Point(63, 22);
268.             this.textBox6.Name = "textBox6";
269.             this.textBox6.Size = new System.Drawing.Size(100, 22);
270.             this.textBox6.TabIndex = 0;
271.             //
272.             // panel2
273.             //
274.             this.panel2.Controls.Add(this.label8);
275.             this.panel2.Controls.Add(this.label7);
276.             this.panel2.Controls.Add(this.label6);
277.             this.panel2.Controls.Add(this.label5);
278.             this.panel2.Controls.Add(this.label4);
279.             this.panel2.Location = new System.Drawing.Point(38, 247);
280.             this.panel2.Name = "panel2";
281.             this.panel2.Size = new System.Drawing.Size(246, 151);
282.             this.panel2.TabIndex = 6;
283.             //
284.             // button1
285.             //
286.             this.button1.Location = new System.Drawing.Point(531, 306);

17 | Page
287.             this.button1.Name = "button1";
288.             this.button1.Size = new System.Drawing.Size(75, 23);
289.             this.button1.TabIndex = 0;
290.             this.button1.Text = "Close";
291.             this.button1.UseVisualStyleBackColor = true;
292.             this.button1.Click += new System.EventHandler(this.button1_Click);
293.             //
294.             // button2
295.             //
296.             this.button2.Location = new System.Drawing.Point(531, 340);
297.             this.button2.Name = "button2";
298.             this.button2.Size = new System.Drawing.Size(75, 23);
299.             this.button2.TabIndex = 7;
300.             this.button2.Text = "Copy";
301.             this.button2.UseVisualStyleBackColor = true;
302.             this.button2.Click += new System.EventHandler(this.button2_Click);
303.             //
304.             // textBox9
305.             //
306.             this.textBox9.Location = new System.Drawing.Point(38, 416);
307.             this.textBox9.Name = "textBox9";
308.             this.textBox9.Size = new System.Drawing.Size(664, 22);
309.             this.textBox9.TabIndex = 8;
310.             //
311.             // label4
312.             //
313.             this.label4.AutoSize = true;
314.             this.label4.Location = new System.Drawing.Point(17, 12);
315.             this.label4.Name = "label4";
316.             this.label4.Size = new System.Drawing.Size(12, 17);
317.             this.label4.TabIndex = 0;
318.             this.label4.Text = " ";
319.             //
320.             // label5
321.             //
322.             this.label5.AutoSize = true;
323.             this.label5.Location = new System.Drawing.Point(48, 47);
324.             this.label5.Name = "label5";
325.             this.label5.Size = new System.Drawing.Size(125, 17);
326.             this.label5.TabIndex = 1;
327.             this.label5.Text = "Sample text as link";
328.             //
329.             // label6
330.             //
331.             this.label6.AutoSize = true;
332.             this.label6.Location = new System.Drawing.Point(48, 79);
333.             this.label6.Name = "label6";
334.             this.label6.Size = new System.Drawing.Size(121, 17);
335.             this.label6.TabIndex = 2;
336.             this.label6.Text = "Current active link";
337.             //
338.             // label7
339.             //
340.             this.label7.AutoSize = true;
341.             this.label7.Location = new System.Drawing.Point(27, 114);
342.             this.label7.Name = "label7";
343.             this.label7.Size = new System.Drawing.Size(167, 17);
344.             this.label7.TabIndex = 3;
345.             this.label7.Text = "This link has been visited";
346.             //
347.             // label8

18 | Page
348.             //
349.             this.label8.AutoSize = true;
350.             this.label8.Location = new System.Drawing.Point(17, 22);
351.             this.label8.Name = "label8";
352.             this.label8.Size = new System.Drawing.Size(211, 17);
353.             this.label8.TabIndex = 4;
354.             this.label8.Text = "Body tag formatter and colorizer";
355.             //
356.             // Form1
357.             //
358.             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
359.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
360.             this.ClientSize = new System.Drawing.Size(717, 450);
361.             this.Controls.Add(this.textBox9);
362.             this.Controls.Add(this.button2);
363.             this.Controls.Add(this.button1);
364.             this.Controls.Add(this.panel2);
365.             this.Controls.Add(this.groupBox2);
366.             this.Controls.Add(this.vScrollBar3);
367.             this.Controls.Add(this.vScrollBar2);
368.             this.Controls.Add(this.vScrollBar1);
369.             this.Controls.Add(this.panel1);
370.             this.Controls.Add(this.groupBox1);
371.             this.Name = "Form1";
372.             this.Text = "Form1";
373.             this.Load += new System.EventHandler(this.Form1_Load);
374.             this.groupBox1.ResumeLayout(false);
375.             this.groupBox1.PerformLayout();
376.             this.groupBox2.ResumeLayout(false);
377.             this.groupBox2.PerformLayout();
378.             this.panel2.ResumeLayout(false);
379.             this.panel2.PerformLayout();
380.             this.ResumeLayout(false);
381.             this.PerformLayout();
382.  
383.         }
384.  
385.         #endregion
386.  
387.         private System.Windows.Forms.GroupBox groupBox1;
388.         private System.Windows.Forms.TextBox visitedText;
389.         private System.Windows.Forms.TextBox activeText;
390.         private System.Windows.Forms.TextBox linkText;
391.         private System.Windows.Forms.TextBox txtText;
392.         private System.Windows.Forms.TextBox bgText;
393.         private System.Windows.Forms.RadioButton visitedButton;
394.         private System.Windows.Forms.RadioButton activeButton;
395.         private System.Windows.Forms.RadioButton linkButton;
396.         private System.Windows.Forms.RadioButton txtButton;
397.         private System.Windows.Forms.RadioButton bgButton;
398.         private System.Windows.Forms.Panel panel1;
399.         private System.Windows.Forms.VScrollBar vScrollBar1;
400.         private System.Windows.Forms.VScrollBar vScrollBar2;
401.         private System.Windows.Forms.VScrollBar vScrollBar3;
402.         private System.Windows.Forms.GroupBox groupBox2;
403.         private System.Windows.Forms.TextBox textBox8;
404.         private System.Windows.Forms.TextBox textBox7;
405.         private System.Windows.Forms.Label label3;
406.         private System.Windows.Forms.Label label2;
407.         private System.Windows.Forms.Label label1;
408.         private System.Windows.Forms.TextBox textBox6;

19 | Page
409.         private System.Windows.Forms.Panel panel2;
410.         private System.Windows.Forms.Button button1;
411.         private System.Windows.Forms.Button button2;
412.         private System.Windows.Forms.TextBox textBox9;
413.         private System.Windows.Forms.Label label7;
414.         private System.Windows.Forms.Label label6;
415.         private System.Windows.Forms.Label label5;
416.         private System.Windows.Forms.Label label4;
417.         private System.Windows.Forms.Label label8;
418.     }
419. }

form1.cs [Design]

Output

20 | Page
21 | Page
4.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculator
{
public partial class Form1 : Form
{
Double firstNum;
String operation;
public Form1()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
if(textBox1.Text=="0" && textBox1.Text != null)
{
textBox1.Text = "8";
}
else
{
textBox1.Text = textBox1.Text + "8";
}
}

private void button4_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "4";
}
else
{
textBox1.Text = textBox1.Text + "4";
}
}

private void button10_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "0";
}
else
{

22 | Page
textBox1.Text = textBox1.Text + "0";
}
}

private void button7_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "1";
}
else
{
textBox1.Text = textBox1.Text + "1";
}
}

private void button8_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "2";
}
else
{
textBox1.Text = textBox1.Text + "2";
}
}

private void button9_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "3";
}
else
{
textBox1.Text = textBox1.Text + "3";
}
}

private void button5_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "5";
}
else
{
textBox1.Text = textBox1.Text + "5";
}
}

private void button6_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "6";
}

23 | Page
else
{
textBox1.Text = textBox1.Text + "6";
}
}

private void button1_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "7";
}
else
{
textBox1.Text = textBox1.Text + "7";
}
}

private void button3_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "9";
}
else
{
textBox1.Text = textBox1.Text + "9";
}
}

private void button13_Click(object sender, EventArgs e)


{
firstNum = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
operation = "+";
}

private void button14_Click(object sender, EventArgs e)


{
firstNum = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
operation = "-";
}

private void button15_Click(object sender, EventArgs e)


{
firstNum = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
operation = "*";
}

private void button18_Click(object sender, EventArgs e)


{
firstNum = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
operation = "/";
}

24 | Page
private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = "0";
}

private void button11_Click(object sender, EventArgs e)


{
textBox1.Text = textBox1.Text + ".";
}

private void button12_Click(object sender, EventArgs e)


{
double secondNum;
double res;
secondNum = Convert.ToDouble(textBox1.Text);
if (operation == "+")
{
res = (firstNum + secondNum);
textBox1.Text = Convert.ToString(res);
firstNum = res;
}
if (operation == "-")
{
res = (firstNum - secondNum);
textBox1.Text = Convert.ToString(res);
firstNum = res;
}
if (operation == "*")
{
res = (firstNum * secondNum);
textBox1.Text = Convert.ToString(res);
firstNum = res;
}
if (operation == "/")
{
if (secondNum == 0)
{
textBox1.Text = "Cannot divide by zero";
}
else
{
res = (firstNum / secondNum);
textBox1.Text = Convert.ToString(res);
firstNum = res;
}
}
}
}
}

Form1.Designer.cs

1. namespace Calculator
2. {
3.     partial class Form1
4.     {
5.         /// <summary>

25 | Page
6.         /// Required designer variable.
7.         /// </summary>
8.         private System.ComponentModel.IContainer components = null;
9.  
10.         /// <summary>
11.         /// Clean up any resources being used.
12.         /// </summary>
13.         /// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
14.         protected override void Dispose(bool disposing)
15.         {
16.             if (disposing && (components != null))
17.             {
18.                 components.Dispose();
19.             }
20.             base.Dispose(disposing);
21.         }
22.  
23.         #region Windows Form Designer generated code
24.  
25.         /// <summary>
26.         /// Required method for Designer support - do not modify
27.         /// the contents of this method with the code editor.
28.         /// </summary>
29.         private void InitializeComponent()
30.         {
31.             this.button1 = new System.Windows.Forms.Button();
32.             this.button2 = new System.Windows.Forms.Button();
33.             this.button3 = new System.Windows.Forms.Button();
34.             this.button4 = new System.Windows.Forms.Button();
35.             this.button5 = new System.Windows.Forms.Button();
36.             this.button6 = new System.Windows.Forms.Button();
37.             this.button7 = new System.Windows.Forms.Button();
38.             this.button8 = new System.Windows.Forms.Button();
39.             this.button9 = new System.Windows.Forms.Button();
40.             this.button10 = new System.Windows.Forms.Button();
41.             this.button11 = new System.Windows.Forms.Button();
42.             this.button12 = new System.Windows.Forms.Button();
43.             this.button13 = new System.Windows.Forms.Button();
44.             this.button14 = new System.Windows.Forms.Button();
45.             this.button15 = new System.Windows.Forms.Button();
46.             this.button16 = new System.Windows.Forms.Button();
47.             this.button18 = new System.Windows.Forms.Button();
48.             this.button19 = new System.Windows.Forms.Button();
49.             this.textBox1 = new System.Windows.Forms.TextBox();
50.             this.SuspendLayout();
51.             //
52.             // button1
53.             //
54.             this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
55.             this.button1.Location = new System.Drawing.Point(37, 114);
56.             this.button1.Name = "button1";
57.             this.button1.Size = new System.Drawing.Size(27, 32);
58.             this.button1.TabIndex = 0;
59.             this.button1.Text = "7";
60.             this.button1.UseVisualStyleBackColor = true;
61.             this.button1.Click += new System.EventHandler(this.button1_Click);
62.             //
63.             // button2
64.             //

26 | Page
65.             this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
66.             this.button2.Location = new System.Drawing.Point(70, 114);
67.             this.button2.Name = "button2";
68.             this.button2.Size = new System.Drawing.Size(27, 32);
69.             this.button2.TabIndex = 1;
70.             this.button2.Text = "8";
71.             this.button2.UseVisualStyleBackColor = true;
72.             //
73.             // button3
74.             //
75.             this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
76.             this.button3.Location = new System.Drawing.Point(103, 114);
77.             this.button3.Name = "button3";
78.             this.button3.Size = new System.Drawing.Size(27, 32);
79.             this.button3.TabIndex = 2;
80.             this.button3.Text = "9";
81.             this.button3.UseVisualStyleBackColor = true;
82.             this.button3.Click += new System.EventHandler(this.button3_Click);
83.             //
84.             // button4
85.             //
86.             this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
87.             this.button4.Location = new System.Drawing.Point(37, 152);
88.             this.button4.Name = "button4";
89.             this.button4.Size = new System.Drawing.Size(27, 32);
90.             this.button4.TabIndex = 3;
91.             this.button4.Text = "4";
92.             this.button4.UseVisualStyleBackColor = true;
93.             this.button4.Click += new System.EventHandler(this.button4_Click);
94.             //
95.             // button5
96.             //
97.             this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
98.             this.button5.Location = new System.Drawing.Point(70, 152);
99.             this.button5.Name = "button5";
100.             this.button5.Size = new System.Drawing.Size(27, 32);
101.             this.button5.TabIndex = 4;
102.             this.button5.Text = "5";
103.             this.button5.UseVisualStyleBackColor = true;
104.             this.button5.Click += new System.EventHandler(this.button5_Click);
105.             //
106.             // button6
107.             //
108.             this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
109.             this.button6.Location = new System.Drawing.Point(103, 152);
110.             this.button6.Name = "button6";
111.             this.button6.Size = new System.Drawing.Size(27, 32);
112.             this.button6.TabIndex = 5;
113.             this.button6.Text = "6";
114.             this.button6.UseVisualStyleBackColor = true;
115.             this.button6.Click += new System.EventHandler(this.button6_Click);
116.             //
117.             // button7
118.             //
119.             this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

27 | Page
120.             this.button7.Location = new System.Drawing.Point(37, 190);
121.             this.button7.Name = "button7";
122.             this.button7.Size = new System.Drawing.Size(27, 32);
123.             this.button7.TabIndex = 6;
124.             this.button7.Text = "1";
125.             this.button7.UseVisualStyleBackColor = true;
126.             this.button7.Click += new System.EventHandler(this.button7_Click);
127.             //
128.             // button8
129.             //
130.             this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
131.             this.button8.Location = new System.Drawing.Point(70, 190);
132.             this.button8.Name = "button8";
133.             this.button8.Size = new System.Drawing.Size(27, 32);
134.             this.button8.TabIndex = 7;
135.             this.button8.Text = "2";
136.             this.button8.UseVisualStyleBackColor = true;
137.             this.button8.Click += new System.EventHandler(this.button8_Click);
138.             //
139.             // button9
140.             //
141.             this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
142.             this.button9.Location = new System.Drawing.Point(103, 190);
143.             this.button9.Name = "button9";
144.             this.button9.Size = new System.Drawing.Size(27, 32);
145.             this.button9.TabIndex = 8;
146.             this.button9.Text = "3";
147.             this.button9.UseVisualStyleBackColor = true;
148.             this.button9.Click += new System.EventHandler(this.button9_Click);
149.             //
150.             // button10
151.             //
152.             this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
153.             this.button10.Location = new System.Drawing.Point(37, 228);
154.             this.button10.Name = "button10";
155.             this.button10.Size = new System.Drawing.Size(60, 32);
156.             this.button10.TabIndex = 9;
157.             this.button10.Text = "0";
158.             this.button10.UseVisualStyleBackColor = true;
159.             this.button10.Click += new System.EventHandler(this.button10_Click);
160.             //
161.             // button11
162.             //
163.             this.button11.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
164.             this.button11.Location = new System.Drawing.Point(103, 228);
165.             this.button11.Name = "button11";
166.             this.button11.Size = new System.Drawing.Size(27, 32);
167.             this.button11.TabIndex = 10;
168.             this.button11.Text = ".";
169.             this.button11.UseVisualStyleBackColor = true;
170.             this.button11.Click += new System.EventHandler(this.button11_Click);
171.             //
172.             // button12
173.             //
174.             this.button12.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
175.             this.button12.Location = new System.Drawing.Point(136, 228);

28 | Page
176.             this.button12.Name = "button12";
177.             this.button12.Size = new System.Drawing.Size(27, 32);
178.             this.button12.TabIndex = 11;
179.             this.button12.Text = "=";
180.             this.button12.UseVisualStyleBackColor = true;
181.             this.button12.Click += new System.EventHandler(this.button12_Click);
182.             //
183.             // button13
184.             //
185.             this.button13.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
186.             this.button13.Location = new System.Drawing.Point(136, 190);
187.             this.button13.Name = "button13";
188.             this.button13.Size = new System.Drawing.Size(27, 32);
189.             this.button13.TabIndex = 12;
190.             this.button13.Text = "+";
191.             this.button13.UseVisualStyleBackColor = true;
192.             this.button13.Click += new System.EventHandler(this.button13_Click);
193.             //
194.             // button14
195.             //
196.             this.button14.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
197.             this.button14.Location = new System.Drawing.Point(136, 152);
198.             this.button14.Name = "button14";
199.             this.button14.Size = new System.Drawing.Size(27, 32);
200.             this.button14.TabIndex = 13;
201.             this.button14.Text = "-";
202.             this.button14.UseVisualStyleBackColor = true;
203.             this.button14.Click += new System.EventHandler(this.button14_Click);
204.             //
205.             // button15
206.             //
207.             this.button15.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
208.             this.button15.Location = new System.Drawing.Point(136, 114);
209.             this.button15.Name = "button15";
210.             this.button15.Size = new System.Drawing.Size(27, 32);
211.             this.button15.TabIndex = 14;
212.             this.button15.Text = "*";
213.             this.button15.UseVisualStyleBackColor = true;
214.             this.button15.Click += new System.EventHandler(this.button15_Click);
215.             //
216.             // button16
217.             //
218.             this.button16.Font = new System.Drawing.Font("Microsoft Sans Serif",
8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
219.             this.button16.Location = new System.Drawing.Point(37, 79);
220.             this.button16.Name = "button16";
221.             this.button16.Size = new System.Drawing.Size(60, 32);
222.             this.button16.TabIndex = 15;
223.             this.button16.Text = "AC";
224.             this.button16.UseVisualStyleBackColor = true;
225.             this.button16.Click += new System.EventHandler(this.button16_Click);
226.             //
227.             // button18
228.             //
229.             this.button18.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
230.             this.button18.Location = new System.Drawing.Point(103, 76);
231.             this.button18.Name = "button18";

29 | Page
232.             this.button18.Size = new System.Drawing.Size(27, 32);
233.             this.button18.TabIndex = 17;
234.             this.button18.Text = "/";
235.             this.button18.UseVisualStyleBackColor = true;
236.             this.button18.Click += new System.EventHandler(this.button18_Click);
237.             //
238.             // button19
239.             //
240.             this.button19.Font = new System.Drawing.Font("Microsoft Sans Serif",
13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
241.             this.button19.Location = new System.Drawing.Point(136, 76);
242.             this.button19.Name = "button19";
243.             this.button19.Size = new System.Drawing.Size(27, 32);
244.             this.button19.TabIndex = 18;
245.             this.button19.Text = "⬅️";
246.             this.button19.UseVisualStyleBackColor = true;
247.             //
248.             // textBox1
249.             //
250.             this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif",
14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
251.             this.textBox1.Location = new System.Drawing.Point(37, 36);
252.             this.textBox1.Name = "textBox1";
253.             this.textBox1.Size = new System.Drawing.Size(126, 34);
254.             this.textBox1.TabIndex = 19;
255.             //
256.             // Form1
257.             //
258.             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
259.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
260.             this.ClientSize = new System.Drawing.Size(199, 297);
261.             this.Controls.Add(this.textBox1);
262.             this.Controls.Add(this.button19);
263.             this.Controls.Add(this.button18);
264.             this.Controls.Add(this.button16);
265.             this.Controls.Add(this.button15);
266.             this.Controls.Add(this.button14);
267.             this.Controls.Add(this.button13);
268.             this.Controls.Add(this.button12);
269.             this.Controls.Add(this.button11);
270.             this.Controls.Add(this.button10);
271.             this.Controls.Add(this.button9);
272.             this.Controls.Add(this.button8);
273.             this.Controls.Add(this.button7);
274.             this.Controls.Add(this.button6);
275.             this.Controls.Add(this.button5);
276.             this.Controls.Add(this.button4);
277.             this.Controls.Add(this.button3);
278.             this.Controls.Add(this.button2);
279.             this.Controls.Add(this.button1);
280.             this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
281.             this.MaximizeBox = false;
282.             this.Name = "Form1";
283.             this.Text = "Form1";
284.             this.ResumeLayout(false);
285.             this.PerformLayout();
286.  
287.         }
288.  
289.         #endregion

30 | Page
290.  
291.         private System.Windows.Forms.Button button1;
292.         private System.Windows.Forms.Button button2;
293.         private System.Windows.Forms.Button button3;
294.         private System.Windows.Forms.Button button4;
295.         private System.Windows.Forms.Button button5;
296.         private System.Windows.Forms.Button button6;
297.         private System.Windows.Forms.Button button7;
298.         private System.Windows.Forms.Button button8;
299.         private System.Windows.Forms.Button button9;
300.         private System.Windows.Forms.Button button10;
301.         private System.Windows.Forms.Button button11;
302.         private System.Windows.Forms.Button button12;
303.         private System.Windows.Forms.Button button13;
304.         private System.Windows.Forms.Button button14;
305.         private System.Windows.Forms.Button button15;
306.         private System.Windows.Forms.Button button16;
307.         private System.Windows.Forms.Button button18;
308.         private System.Windows.Forms.Button button19;
309.         private System.Windows.Forms.TextBox textBox1;
310.     }
311. }

Form1.cs [Design]

Output

31 | Page
32 | Page
5.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Registration_form
{
public partial class Form1 : Form
{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\labsheet 2\Registration form\Registration Form.accdb");
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void textBox1_TextChanged(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
try
{
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
String name = textBox1.Text;
String address = richTextBox1.Text;
String contact = textBox3.Text;
String gender = textBox4.Text;
String email = textBox5.Text;
cmd.CommandText = "INSERT INTO
Registration(Person,Address,Contact,Gender,Email_ID) VALUES ('" + name + "','" +
address + "','" + contact + "','" + gender + "','" + email + "')";;
cmd.ExecuteNonQuery();
MessageBox.Show("Record saved in Database", "Connected to
Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
conn.Close();
}
catch (Exception err)

33 | Page
{
MessageBox.Show(err.Message, "Connected to Database",
MessageBoxButtons.OK, MessageBoxIcon.Information);
conn.Close();
}
}
}
}

Form1.Designer.cs

1. namespace Registration_form
2. {
3.     partial class Form1
4.     {
5.         /// <summary>
6.         /// Required designer variable.
7.         /// </summary>
8.         private System.ComponentModel.IContainer components = null;
9.  
10.         /// <summary>
11.         /// Clean up any resources being used.
12.         /// </summary>
13.         /// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
14.         protected override void Dispose(bool disposing)
15.         {
16.             if (disposing && (components != null))
17.             {
18.                 components.Dispose();
19.             }
20.             base.Dispose(disposing);
21.         }
22.  
23.         #region Windows Form Designer generated code
24.  
25.         /// <summary>
26.         /// Required method for Designer support - do not modify
27.         /// the contents of this method with the code editor.
28.         /// </summary>
29.         private void InitializeComponent()
30.         {
31.             this.groupBox1 = new System.Windows.Forms.GroupBox();
32.             this.label1 = new System.Windows.Forms.Label();
33.             this.textBox1 = new System.Windows.Forms.TextBox();
34.             this.label2 = new System.Windows.Forms.Label();
35.             this.textBox3 = new System.Windows.Forms.TextBox();
36.             this.label3 = new System.Windows.Forms.Label();
37.             this.textBox4 = new System.Windows.Forms.TextBox();
38.             this.label4 = new System.Windows.Forms.Label();
39.             this.textBox5 = new System.Windows.Forms.TextBox();
40.             this.label5 = new System.Windows.Forms.Label();
41.             this.richTextBox1 = new System.Windows.Forms.RichTextBox();
42.             this.button1 = new System.Windows.Forms.Button();
43.             this.groupBox1.SuspendLayout();
44.             this.SuspendLayout();
45.             //
46.             // groupBox1
47.             //

34 | Page
48.             this.groupBox1.Controls.Add(this.button1);
49.             this.groupBox1.Controls.Add(this.richTextBox1);
50.             this.groupBox1.Controls.Add(this.textBox5);
51.             this.groupBox1.Controls.Add(this.label5);
52.             this.groupBox1.Controls.Add(this.textBox4);
53.             this.groupBox1.Controls.Add(this.label4);
54.             this.groupBox1.Controls.Add(this.textBox3);
55.             this.groupBox1.Controls.Add(this.label3);
56.             this.groupBox1.Controls.Add(this.label2);
57.             this.groupBox1.Controls.Add(this.textBox1);
58.             this.groupBox1.Controls.Add(this.label1);
59.             this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
60.             this.groupBox1.Location = new System.Drawing.Point(12, 12);
61.             this.groupBox1.Name = "groupBox1";
62.             this.groupBox1.Size = new System.Drawing.Size(317, 366);
63.             this.groupBox1.TabIndex = 0;
64.             this.groupBox1.TabStop = false;
65.             this.groupBox1.Text = "Registration Form";
66.             //
67.             // label1
68.             //
69.             this.label1.AutoSize = true;
70.             this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
71.             this.label1.Location = new System.Drawing.Point(7, 40);
72.             this.label1.Name = "label1";
73.             this.label1.Size = new System.Drawing.Size(57, 20);
74.             this.label1.TabIndex = 0;
75.             this.label1.Text = "Name";
76.             //
77.             // textBox1
78.             //
79.             this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
80.             this.textBox1.Location = new System.Drawing.Point(91, 40);
81.             this.textBox1.Name = "textBox1";
82.             this.textBox1.Size = new System.Drawing.Size(202, 28);
83.             this.textBox1.TabIndex = 1;
84.             this.textBox1.TextChanged += new
System.EventHandler(this.textBox1_TextChanged);
85.             //
86.             // label2
87.             //
88.             this.label2.AutoSize = true;
89.             this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
90.             this.label2.Location = new System.Drawing.Point(7, 86);
91.             this.label2.Name = "label2";
92.             this.label2.Size = new System.Drawing.Size(78, 20);
93.             this.label2.TabIndex = 2;
94.             this.label2.Text = "Address";
95.             //
96.             // textBox3
97.             //
98.             this.textBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
99.             this.textBox3.Location = new System.Drawing.Point(91, 164);
100.             this.textBox3.Name = "textBox3";
101.             this.textBox3.Size = new System.Drawing.Size(202, 28);
102.             this.textBox3.TabIndex = 5;

35 | Page
103.             //
104.             // label3
105.             //
106.             this.label3.AutoSize = true;
107.             this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif",
10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
108.             this.label3.Location = new System.Drawing.Point(7, 164);
109.             this.label3.Name = "label3";
110.             this.label3.Size = new System.Drawing.Size(74, 20);
111.             this.label3.TabIndex = 4;
112.             this.label3.Text = "Contact";
113.             //
114.             // textBox4
115.             //
116.             this.textBox4.Font = new System.Drawing.Font("Microsoft Sans Serif",
11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
117.             this.textBox4.Location = new System.Drawing.Point(91, 212);
118.             this.textBox4.Name = "textBox4";
119.             this.textBox4.Size = new System.Drawing.Size(202, 28);
120.             this.textBox4.TabIndex = 7;
121.             //
122.             // label4
123.             //
124.             this.label4.AutoSize = true;
125.             this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif",
10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
126.             this.label4.Location = new System.Drawing.Point(7, 212);
127.             this.label4.Name = "label4";
128.             this.label4.Size = new System.Drawing.Size(70, 20);
129.             this.label4.TabIndex = 6;
130.             this.label4.Text = "Gender";
131.             //
132.             // textBox5
133.             //
134.             this.textBox5.Font = new System.Drawing.Font("Microsoft Sans Serif",
11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
135.             this.textBox5.Location = new System.Drawing.Point(91, 261);
136.             this.textBox5.Name = "textBox5";
137.             this.textBox5.Size = new System.Drawing.Size(202, 28);
138.             this.textBox5.TabIndex = 9;
139.             //
140.             // label5
141.             //
142.             this.label5.AutoSize = true;
143.             this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif",
10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
144.             this.label5.Location = new System.Drawing.Point(7, 261);
145.             this.label5.Name = "label5";
146.             this.label5.Size = new System.Drawing.Size(81, 20);
147.             this.label5.TabIndex = 8;
148.             this.label5.Text = "Email ID";
149.             //
150.             // richTextBox1
151.             //
152.             this.richTextBox1.Location = new System.Drawing.Point(91, 86);
153.             this.richTextBox1.Name = "richTextBox1";
154.             this.richTextBox1.Size = new System.Drawing.Size(202, 72);
155.             this.richTextBox1.TabIndex = 10;
156.             this.richTextBox1.Text = "";
157.             //
158.             // button1

36 | Page
159.             //
160.             this.button1.Location = new System.Drawing.Point(190, 306);
161.             this.button1.Name = "button1";
162.             this.button1.Size = new System.Drawing.Size(103, 36);
163.             this.button1.TabIndex = 11;
164.             this.button1.Text = "Register";
165.             this.button1.UseVisualStyleBackColor = true;
166.             this.button1.Click += new System.EventHandler(this.button1_Click);
167.             //
168.             // Form1
169.             //
170.             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
171.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
172.             this.ClientSize = new System.Drawing.Size(336, 377);
173.             this.Controls.Add(this.groupBox1);
174.             this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
175.             this.MaximizeBox = false;
176.             this.Name = "Form1";
177.             this.Text = "Form1";
178.             this.Load += new System.EventHandler(this.Form1_Load);
179.             this.groupBox1.ResumeLayout(false);
180.             this.groupBox1.PerformLayout();
181.             this.ResumeLayout(false);
182.  
183.         }
184.  
185.         #endregion
186.  
187.         private System.Windows.Forms.GroupBox groupBox1;
188.         private System.Windows.Forms.TextBox textBox1;
189.         private System.Windows.Forms.Label label1;
190.         private System.Windows.Forms.Button button1;
191.         private System.Windows.Forms.RichTextBox richTextBox1;
192.         private System.Windows.Forms.TextBox textBox5;
193.         private System.Windows.Forms.Label label5;
194.         private System.Windows.Forms.TextBox textBox4;
195.         private System.Windows.Forms.Label label4;
196.         private System.Windows.Forms.TextBox textBox3;
197.         private System.Windows.Forms.Label label3;
198.         private System.Windows.Forms.Label label2;
199.     }
200. }

Form1.cs [Design]

37 | Page
Output

38 | Page
39 | Page
6.

Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Database_Exercise
{
public partial class Form1 : Form
{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\database exercise\Database1.accdb");
public Form1()
{
InitializeComponent();
FillData();
}
void FillData()
{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\database exercise\Database1.accdb");
string query = "SELECT * From AddressBook";
using (conn)
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(query,
conn))
{
DataSet ds = new DataSet();
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
}

}
void ClearData()
{
textBox1.Text = null;
richTextBox1.Text = null;
textBox3.Text = null;
textBox4.Text = null;
textBox5.Text = null;
textBox6.Text = null;
textBox7.Text = null;
}

private void button1_Click(object sender, EventArgs e)


{

40 | Page
try
{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\database exercise\Database1.accdb");
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
//MessageBox.Show("opened connection ! ");
String name = textBox1.Text;
String address = richTextBox1.Text;
String contact = textBox3.Text;
String houseNo = textBox4.Text;
String pin = textBox5.Text;
String location = textBox6.Text;
String district = textBox7.Text;
cmd.CommandText = "INSERT INTO
AddressBook(Person,houseName,contact,houseNo,pin,location,district) VALUES ('" +
name + "','" + address + "','" + contact + "','" + houseNo + "','" + pin + "','" +
location + "','" + district + "')"; ;
cmd.ExecuteNonQuery();
MessageBox.Show("Record saved in Database", "Connected to
Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
FillData();
ClearData();
cmd.Dispose();
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! "+ex);
}
}

private void Form1_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the
'database1DataSet.AddressBook' table. You can move, or remove it, as needed.
this.addressBookTableAdapter.Fill(this.database1DataSet.AddressBook);

private void button2_Click(object sender, EventArgs e)


{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\database exercise\Database1.accdb");
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
String contact = textBox3.Text;
String address = richTextBox1.Text;
cmd.CommandText = "UPDATE AddressBook SET houseName='" + address + "'
where contact='" + contact + "'"; ;
cmd.ExecuteNonQuery();
MessageBox.Show("Record updated in Database", "Connected to Database",
MessageBoxButtons.OK, MessageBoxIcon.Information);
FillData();
ClearData();
cmd.Dispose();

41 | Page
conn.Close();

private void button3_Click(object sender, EventArgs e)


{
try
{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\database exercise\Database1.accdb");
String name = textBox1.Text;
String contact = textBox3.Text;
String sql = "Select * from AddressBook where Person='" + name +
"' AND contact='" + contact + "'"; ;
conn.Open();
using (conn)
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(sql,
conn))
{
DataSet ds = new DataSet();
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
}
ClearData();
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error" + ex);
}
}

private void button4_Click(object sender, EventArgs e)


{
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\BCA\s5\C#
and .net\works\forms\database exercise\Database1.accdb");
String name = textBox1.Text;
String sql = "Delete from AddressBook where Person='" + name + "'"; ;
try
{
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
MessageBox.Show("Record deleted in Database", "Connected to
Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
FillData();
ClearData();
cmd.Dispose();
conn.Close();
}
catch(Exception er)
{
MessageBox.Show(er.Message);

42 | Page
}
}

private void button5_Click(object sender, EventArgs e)


{
FillData();
}
}

}
Form1.Designer.cs

1. namespace Database_Exercise
2. {
3.     partial class Form1
4.     {
5.         /// <summary>
6.         /// Required designer variable.
7.         /// </summary>
8.         private System.ComponentModel.IContainer components = null;
9.  
10.         /// <summary>
11.         /// Clean up any resources being used.
12.         /// </summary>
13.         /// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
14.         protected override void Dispose(bool disposing)
15.         {
16.             if (disposing && (components != null))
17.             {
18.                 components.Dispose();
19.             }
20.             base.Dispose(disposing);
21.         }
22.  
23.         #region Windows Form Designer generated code
24.  
25.         /// <summary>
26.         /// Required method for Designer support - do not modify
27.         /// the contents of this method with the code editor.
28.         /// </summary>
29.         private void InitializeComponent()
30.         {
31.             this.components = new System.ComponentModel.Container();
32.             this.button1 = new System.Windows.Forms.Button();
33.             this.label1 = new System.Windows.Forms.Label();
34.             this.textBox1 = new System.Windows.Forms.TextBox();
35.             this.label2 = new System.Windows.Forms.Label();
36.             this.textBox3 = new System.Windows.Forms.TextBox();
37.             this.label3 = new System.Windows.Forms.Label();
38.             this.textBox4 = new System.Windows.Forms.TextBox();
39.             this.label4 = new System.Windows.Forms.Label();
40.             this.textBox5 = new System.Windows.Forms.TextBox();
41.             this.label5 = new System.Windows.Forms.Label();
42.             this.textBox6 = new System.Windows.Forms.TextBox();
43.             this.label6 = new System.Windows.Forms.Label();
44.             this.textBox7 = new System.Windows.Forms.TextBox();
45.             this.label7 = new System.Windows.Forms.Label();
46.             this.richTextBox1 = new System.Windows.Forms.RichTextBox();
47.             this.button2 = new System.Windows.Forms.Button();

43 | Page
48.             this.button3 = new System.Windows.Forms.Button();
49.             this.button4 = new System.Windows.Forms.Button();
50.             this.dataGridView1 = new System.Windows.Forms.DataGridView();
51.             this.database1DataSet = new Database_Exercise.Database1DataSet();
52.             this.addressBookBindingSource = new
System.Windows.Forms.BindingSource(this.components);
53.             this.addressBookTableAdapter = new
Database_Exercise.Database1DataSetTableAdapters.AddressBookTableAdapter();
54.             this.personDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
55.             this.houseNameDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
56.             this.contactDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
57.             this.houseNoDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
58.             this.pinDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
59.             this.locationDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
60.             this.districtDataGridViewTextBoxColumn = new
System.Windows.Forms.DataGridViewTextBoxColumn();
61.             this.button5 = new System.Windows.Forms.Button();
62.             ((System.ComponentModel.ISupportInitialize)
(this.dataGridView1)).BeginInit();
63.             ((System.ComponentModel.ISupportInitialize)
(this.database1DataSet)).BeginInit();
64.             ((System.ComponentModel.ISupportInitialize)
(this.addressBookBindingSource)).BeginInit();
65.             this.SuspendLayout();
66.             //
67.             // button1
68.             //
69.             this.button1.Location = new System.Drawing.Point(105, 389);
70.             this.button1.Name = "button1";
71.             this.button1.Size = new System.Drawing.Size(75, 23);
72.             this.button1.TabIndex = 0;
73.             this.button1.Text = "Save";
74.             this.button1.UseVisualStyleBackColor = true;
75.             this.button1.Click += new System.EventHandler(this.button1_Click);
76.             //
77.             // label1
78.             //
79.             this.label1.AutoSize = true;
80.             this.label1.Location = new System.Drawing.Point(31, 22);
81.             this.label1.Name = "label1";
82.             this.label1.Size = new System.Drawing.Size(45, 17);
83.             this.label1.TabIndex = 1;
84.             this.label1.Text = "Name";
85.             //
86.             // textBox1
87.             //
88.             this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.addressBookBindingSource, "Person", true));
89.             this.textBox1.Location = new System.Drawing.Point(135, 22);
90.             this.textBox1.Name = "textBox1";
91.             this.textBox1.Size = new System.Drawing.Size(100, 22);
92.             this.textBox1.TabIndex = 0;
93.             //
94.             // label2
95.             //

44 | Page
96.             this.label2.AutoSize = true;
97.             this.label2.Location = new System.Drawing.Point(31, 62);
98.             this.label2.Name = "label2";
99.             this.label2.Size = new System.Drawing.Size(90, 17);
100.             this.label2.TabIndex = 3;
101.             this.label2.Text = "House Name";
102.             //
103.             // textBox3
104.             //
105.             this.textBox3.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.addressBookBindingSource, "contact", true));
106.             this.textBox3.Location = new System.Drawing.Point(135, 119);
107.             this.textBox3.Name = "textBox3";
108.             this.textBox3.Size = new System.Drawing.Size(100, 22);
109.             this.textBox3.TabIndex = 2;
110.             //
111.             // label3
112.             //
113.             this.label3.AutoSize = true;
114.             this.label3.Location = new System.Drawing.Point(31, 119);
115.             this.label3.Name = "label3";
116.             this.label3.Size = new System.Drawing.Size(56, 17);
117.             this.label3.TabIndex = 5;
118.             this.label3.Text = "Contact";
119.             //
120.             // textBox4
121.             //
122.             this.textBox4.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.addressBookBindingSource, "houseNo", true));
123.             this.textBox4.Location = new System.Drawing.Point(135, 169);
124.             this.textBox4.Name = "textBox4";
125.             this.textBox4.Size = new System.Drawing.Size(100, 22);
126.             this.textBox4.TabIndex = 3;
127.             //
128.             // label4
129.             //
130.             this.label4.AutoSize = true;
131.             this.label4.Location = new System.Drawing.Point(31, 169);
132.             this.label4.Name = "label4";
133.             this.label4.Size = new System.Drawing.Size(75, 17);
134.             this.label4.TabIndex = 7;
135.             this.label4.Text = "House No.";
136.             //
137.             // textBox5
138.             //
139.             this.textBox5.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.addressBookBindingSource, "pin", true));
140.             this.textBox5.Location = new System.Drawing.Point(135, 212);
141.             this.textBox5.Name = "textBox5";
142.             this.textBox5.Size = new System.Drawing.Size(100, 22);
143.             this.textBox5.TabIndex = 4;
144.             //
145.             // label5
146.             //
147.             this.label5.AutoSize = true;
148.             this.label5.Location = new System.Drawing.Point(31, 212);
149.             this.label5.Name = "label5";
150.             this.label5.Size = new System.Drawing.Size(65, 17);
151.             this.label5.TabIndex = 9;
152.             this.label5.Text = "Pin Code";
153.             //

45 | Page
154.             // textBox6
155.             //
156.             this.textBox6.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.addressBookBindingSource, "location", true));
157.             this.textBox6.Location = new System.Drawing.Point(135, 264);
158.             this.textBox6.Name = "textBox6";
159.             this.textBox6.Size = new System.Drawing.Size(100, 22);
160.             this.textBox6.TabIndex = 5;
161.             //
162.             // label6
163.             //
164.             this.label6.AutoSize = true;
165.             this.label6.Location = new System.Drawing.Point(31, 264);
166.             this.label6.Name = "label6";
167.             this.label6.Size = new System.Drawing.Size(62, 17);
168.             this.label6.TabIndex = 11;
169.             this.label6.Text = "Location";
170.             //
171.             // textBox7
172.             //
173.             this.textBox7.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.addressBookBindingSource, "district", true));
174.             this.textBox7.Location = new System.Drawing.Point(135, 315);
175.             this.textBox7.Name = "textBox7";
176.             this.textBox7.Size = new System.Drawing.Size(100, 22);
177.             this.textBox7.TabIndex = 6;
178.             //
179.             // label7
180.             //
181.             this.label7.AutoSize = true;
182.             this.label7.Location = new System.Drawing.Point(31, 315);
183.             this.label7.Name = "label7";
184.             this.label7.Size = new System.Drawing.Size(51, 17);
185.             this.label7.TabIndex = 13;
186.             this.label7.Text = "District";
187.             //
188.             // richTextBox1
189.             //
190.             this.richTextBox1.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.addressBookBindingSource, "houseName",
true));
191.             this.richTextBox1.Location = new System.Drawing.Point(135, 62);
192.             this.richTextBox1.Name = "richTextBox1";
193.             this.richTextBox1.Size = new System.Drawing.Size(170, 51);
194.             this.richTextBox1.TabIndex = 1;
195.             this.richTextBox1.Text = "";
196.             //
197.             // button2
198.             //
199.             this.button2.Location = new System.Drawing.Point(204, 389);
200.             this.button2.Name = "button2";
201.             this.button2.Size = new System.Drawing.Size(75, 23);
202.             this.button2.TabIndex = 16;
203.             this.button2.Text = "Update";
204.             this.button2.UseVisualStyleBackColor = true;
205.             this.button2.Click += new System.EventHandler(this.button2_Click);
206.             //
207.             // button3
208.             //
209.             this.button3.Location = new System.Drawing.Point(297, 389);
210.             this.button3.Name = "button3";

46 | Page
211.             this.button3.Size = new System.Drawing.Size(75, 23);
212.             this.button3.TabIndex = 17;
213.             this.button3.Text = "Search";
214.             this.button3.UseVisualStyleBackColor = true;
215.             this.button3.Click += new System.EventHandler(this.button3_Click);
216.             //
217.             // button4
218.             //
219.             this.button4.Location = new System.Drawing.Point(395, 389);
220.             this.button4.Name = "button4";
221.             this.button4.Size = new System.Drawing.Size(75, 23);
222.             this.button4.TabIndex = 18;
223.             this.button4.Text = "Delete";
224.             this.button4.UseVisualStyleBackColor = true;
225.             this.button4.Click += new System.EventHandler(this.button4_Click);
226.             //
227.             // dataGridView1
228.             //
229.             this.dataGridView1.AllowUserToOrderColumns = true;
230.             this.dataGridView1.AutoGenerateColumns = false;
231.             this.dataGridView1.AutoSizeColumnsMode =
System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
232.             this.dataGridView1.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D;
233.             this.dataGridView1.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
234.             this.dataGridView1.Columns.AddRange(new
System.Windows.Forms.DataGridViewColumn[] {
235.             this.personDataGridViewTextBoxColumn,
236.             this.houseNameDataGridViewTextBoxColumn,
237.             this.contactDataGridViewTextBoxColumn,
238.             this.houseNoDataGridViewTextBoxColumn,
239.             this.pinDataGridViewTextBoxColumn,
240.             this.locationDataGridViewTextBoxColumn,
241.             this.districtDataGridViewTextBoxColumn});
242.             this.dataGridView1.DataSource = this.addressBookBindingSource;
243.             this.dataGridView1.Location = new System.Drawing.Point(311, 12);
244.             this.dataGridView1.Name = "dataGridView1";
245.             this.dataGridView1.RowHeadersWidth = 51;
246.             this.dataGridView1.RowTemplate.Height = 24;
247.             this.dataGridView1.Size = new System.Drawing.Size(1047, 352);
248.             this.dataGridView1.TabIndex = 7;
249.             //
250.             // database1DataSet
251.             //
252.             this.database1DataSet.DataSetName = "Database1DataSet";
253.             this.database1DataSet.SchemaSerializationMode =
System.Data.SchemaSerializationMode.IncludeSchema;
254.             //
255.             // addressBookBindingSource
256.             //
257.             this.addressBookBindingSource.DataMember = "AddressBook";
258.             this.addressBookBindingSource.DataSource = this.database1DataSet;
259.             //
260.             // addressBookTableAdapter
261.             //
262.             this.addressBookTableAdapter.ClearBeforeFill = true;
263.             //
264.             // personDataGridViewTextBoxColumn
265.             //
266.             this.personDataGridViewTextBoxColumn.DataPropertyName = "Person";

47 | Page
267.             this.personDataGridViewTextBoxColumn.HeaderText = "Person";
268.             this.personDataGridViewTextBoxColumn.MinimumWidth = 6;
269.             this.personDataGridViewTextBoxColumn.Name =
"personDataGridViewTextBoxColumn";
270.             //
271.             // houseNameDataGridViewTextBoxColumn
272.             //
273.             this.houseNameDataGridViewTextBoxColumn.DataPropertyName =
"houseName";
274.             this.houseNameDataGridViewTextBoxColumn.HeaderText = "houseName";
275.             this.houseNameDataGridViewTextBoxColumn.MinimumWidth = 6;
276.             this.houseNameDataGridViewTextBoxColumn.Name =
"houseNameDataGridViewTextBoxColumn";
277.             //
278.             // contactDataGridViewTextBoxColumn
279.             //
280.             this.contactDataGridViewTextBoxColumn.DataPropertyName = "contact";
281.             this.contactDataGridViewTextBoxColumn.HeaderText = "contact";
282.             this.contactDataGridViewTextBoxColumn.MinimumWidth = 6;
283.             this.contactDataGridViewTextBoxColumn.Name =
"contactDataGridViewTextBoxColumn";
284.             //
285.             // houseNoDataGridViewTextBoxColumn
286.             //
287.             this.houseNoDataGridViewTextBoxColumn.DataPropertyName = "houseNo";
288.             this.houseNoDataGridViewTextBoxColumn.HeaderText = "houseNo";
289.             this.houseNoDataGridViewTextBoxColumn.MinimumWidth = 6;
290.             this.houseNoDataGridViewTextBoxColumn.Name =
"houseNoDataGridViewTextBoxColumn";
291.             //
292.             // pinDataGridViewTextBoxColumn
293.             //
294.             this.pinDataGridViewTextBoxColumn.DataPropertyName = "pin";
295.             this.pinDataGridViewTextBoxColumn.HeaderText = "pin";
296.             this.pinDataGridViewTextBoxColumn.MinimumWidth = 6;
297.             this.pinDataGridViewTextBoxColumn.Name =
"pinDataGridViewTextBoxColumn";
298.             //
299.             // locationDataGridViewTextBoxColumn
300.             //
301.             this.locationDataGridViewTextBoxColumn.DataPropertyName =
"location";
302.             this.locationDataGridViewTextBoxColumn.HeaderText = "location";
303.             this.locationDataGridViewTextBoxColumn.MinimumWidth = 6;
304.             this.locationDataGridViewTextBoxColumn.Name =
"locationDataGridViewTextBoxColumn";
305.             //
306.             // districtDataGridViewTextBoxColumn
307.             //
308.             this.districtDataGridViewTextBoxColumn.DataPropertyName =
"district";
309.             this.districtDataGridViewTextBoxColumn.HeaderText = "district";
310.             this.districtDataGridViewTextBoxColumn.MinimumWidth = 6;
311.             this.districtDataGridViewTextBoxColumn.Name =
"districtDataGridViewTextBoxColumn";
312.             //
313.             // button5
314.             //
315.             this.button5.Location = new System.Drawing.Point(7, 389);
316.             this.button5.Name = "button5";
317.             this.button5.Size = new System.Drawing.Size(75, 23);

48 | Page
318.             this.button5.TabIndex = 19;
319.             this.button5.Text = "Print";
320.             this.button5.UseVisualStyleBackColor = true;
321.             this.button5.Click += new System.EventHandler(this.button5_Click);
322.             //
323.             // Form1
324.             //
325.             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
326.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
327.             this.ClientSize = new System.Drawing.Size(1365, 450);
328.             this.Controls.Add(this.button5);
329.             this.Controls.Add(this.dataGridView1);
330.             this.Controls.Add(this.button4);
331.             this.Controls.Add(this.button3);
332.             this.Controls.Add(this.button2);
333.             this.Controls.Add(this.richTextBox1);
334.             this.Controls.Add(this.textBox7);
335.             this.Controls.Add(this.label7);
336.             this.Controls.Add(this.textBox6);
337.             this.Controls.Add(this.label6);
338.             this.Controls.Add(this.textBox5);
339.             this.Controls.Add(this.label5);
340.             this.Controls.Add(this.textBox4);
341.             this.Controls.Add(this.label4);
342.             this.Controls.Add(this.textBox3);
343.             this.Controls.Add(this.label3);
344.             this.Controls.Add(this.label2);
345.             this.Controls.Add(this.textBox1);
346.             this.Controls.Add(this.label1);
347.             this.Controls.Add(this.button1);
348.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
349.             this.Name = "Form1";
350.             this.Text = "Form1";
351.             this.Load += new System.EventHandler(this.Form1_Load);
352.             ((System.ComponentModel.ISupportInitialize)
(this.dataGridView1)).EndInit();
353.             ((System.ComponentModel.ISupportInitialize)
(this.database1DataSet)).EndInit();
354.             ((System.ComponentModel.ISupportInitialize)
(this.addressBookBindingSource)).EndInit();
355.             this.ResumeLayout(false);
356.             this.PerformLayout();
357.  
358.         }
359.  
360.         #endregion
361.  
362.         private System.Windows.Forms.Button button1;
363.         private System.Windows.Forms.Label label1;
364.         private System.Windows.Forms.TextBox textBox1;
365.         private System.Windows.Forms.Label label2;
366.         private System.Windows.Forms.TextBox textBox3;
367.         private System.Windows.Forms.Label label3;
368.         private System.Windows.Forms.TextBox textBox4;
369.         private System.Windows.Forms.Label label4;
370.         private System.Windows.Forms.TextBox textBox5;
371.         private System.Windows.Forms.Label label5;
372.         private System.Windows.Forms.TextBox textBox6;
373.         private System.Windows.Forms.Label label6;
374.         private System.Windows.Forms.TextBox textBox7;
375.         private System.Windows.Forms.Label label7;

49 | Page
376.         private System.Windows.Forms.RichTextBox richTextBox1;
377.         private System.Windows.Forms.Button button2;
378.         private System.Windows.Forms.Button button3;
379.         private System.Windows.Forms.Button button4;
380.         private System.Windows.Forms.DataGridView dataGridView1;
381.         private Database1DataSet database1DataSet;
382.         private System.Windows.Forms.BindingSource addressBookBindingSource;
383.         private Database1DataSetTableAdapters.AddressBookTableAdapter
addressBookTableAdapter;
384.         private System.Windows.Forms.DataGridViewTextBoxColumn
personDataGridViewTextBoxColumn;
385.         private System.Windows.Forms.DataGridViewTextBoxColumn
houseNameDataGridViewTextBoxColumn;
386.         private System.Windows.Forms.DataGridViewTextBoxColumn
contactDataGridViewTextBoxColumn;
387.         private System.Windows.Forms.DataGridViewTextBoxColumn
houseNoDataGridViewTextBoxColumn;
388.         private System.Windows.Forms.DataGridViewTextBoxColumn
pinDataGridViewTextBoxColumn;
389.         private System.Windows.Forms.DataGridViewTextBoxColumn
locationDataGridViewTextBoxColumn;
390.         private System.Windows.Forms.DataGridViewTextBoxColumn
districtDataGridViewTextBoxColumn;
391.         private System.Windows.Forms.Button button5;
392.     }
393. }

Form1.cs [Design]

50 | Page
Output

51 | Page
● Clicking on the Save button adds data to the table from the entered field

● Clicking on the Update button updates the houseName of the field that matches the entered
mobile number/ contact
● Clicking on the Search button prints the data from the table which matches the entered name
and contact.
● Clicking on the Delete button deletes the field from the table which matches the entered name.

● The Print button is just for populating the data from the table into the Data Grid View

Access Database Data

52 | Page
53 | Page

You might also like