using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using System.Drawing;
using System.Data.SqlClient;
using System.Windows.Forms;
public class Form1 : System.Windows.Forms.Form
{
private Button changeItemBtn = new Button();
private DataGridView customersDataGridView = new DataGridView();
private BindingSource customersBindingSource = new BindingSource();
public Form1()
{
this.changeItemBtn.Text = "Change Item";
this.changeItemBtn.Dock = DockStyle.Bottom;
this.changeItemBtn.Click += new EventHandler(changeItemBtn_Click);
this.Controls.Add(this.changeItemBtn);
customersDataGridView.Dock = DockStyle.Top;
this.Controls.Add(customersDataGridView);
this.Size = new Size(800, 200);
this.Load += new EventHandler(Form1_Load);
}
private void Form1_Load(System.Object sender, System.EventArgs e)
{
List customerList = new List();
customerList.Add(Employee.CreateNewEmployee());
this.customersBindingSource.DataSource = customerList;
this.customersDataGridView.DataSource = this.customersBindingSource;
}
void changeItemBtn_Click(object sender, EventArgs e)
{
List customerList = this.customersBindingSource.DataSource as List;
customerList[0].CompanyName = "Abc";
this.customersBindingSource.ResetItem(0);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
public class Employee
{
private Guid idValue = Guid.NewGuid();
private string employeeName = String.Empty;
private string companyNameValue = String.Empty;
private string phoneNumberValue = String.Empty;
private Employee()
{
employeeName = "no data";
companyNameValue = "no data";
phoneNumberValue = "no data";
}
public static Employee CreateNewEmployee()
{
return new Employee();
}
public Guid ID
{
get
{
return this.idValue;
}
}
public string CompanyName
{
get
{
return this.companyNameValue;
}
set
{
this.companyNameValue = value;
}
}
public string PhoneNumber
{
get
{
return this.phoneNumberValue;
}
set
{
this.phoneNumberValue = value;
}
}
}