This is A C# Practice code:
Video For Result:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace database
- {
- public partial class GridAddComponent : Form
- {
- public GridAddComponent()
- {
- InitializeComponent();
- }
- private void GridAddComponent_Load(object sender, EventArgs e)
- {
- DataTable table = new DataTable();
- table.Columns.Add("ID", typeof(int));
- table.Columns.Add("Name", typeof(string));
- table.Columns.Add("Degree", typeof(string));
- table.Columns.Add("year", typeof(string));
- table.Columns.Add("mobile", typeof(string));
- table.Rows.Add(1,"Mohan","BE",2,9);
- table.Rows.Add(2, "ram", "BE", 2012, 9767976986);
- table.Rows.Add(3, "Babu", "Bse", 2012, 9767976986);
- table.Rows.Add(4, "Somu", "BE", 2012, 9767976986);
- table.Rows.Add(5, "Mohan", "Bse", 2012, 9767976986);
- table.Rows.Add(6, "Prabha", "BE", 2012, 9767976986);
- table.Rows.Add(7, "Mohan", "BE", 2012, 9767976986);
- dataGridView2.DataSource = table;
- //ADD Button
- DataGridViewButtonColumn Btn = new DataGridViewButtonColumn();
- Btn.HeaderText = "Buttons";
- dataGridView2.Columns.Add(Btn);
- //ADD Image
- DataGridViewImageColumn Images = new DataGridViewImageColumn();
- Images.HeaderText = "Image";
- dataGridView2.Columns.Add(Images);
- //ADD CheckBox
- DataGridViewCheckBoxColumn check = new DataGridViewCheckBoxColumn();
- check.HeaderText = "CheckBox";
- dataGridView2.Columns.Add(check);
- //ADD LinkBox
- DataGridViewLinkColumn link = new DataGridViewLinkColumn();
- link.HeaderText = "Page Link";
- dataGridView2.Columns.Add(link);
- //ADD ComboBox
- DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
- combo.HeaderText = "List";
- combo.Items.Add("2123");
- combo.Items.Add("gdsg");
- combo.Items.Add("dghsdfg");
- combo.Items.Add("gdfgsdg");
- combo.Items.Add("2142ew23");
- combo.Items.Add("21f23");
- dataGridView2.Columns.Add(combo);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- DialogResult aaa = MessageBox.Show("kjhkgha","vzxfvfzxv",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
- if (aaa == DialogResult.Yes)
- {
- MessageBox.Show("kjhkgha", "vzxfvfzxv", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
- }
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- }
- }
Facebook Comment