Using system.drawing; using system.collections; using system.windows.form; using system.data; using system.data.sqlclient;
A summary description of Namespace WindowsApplication1 {///
Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();
// // Todo: Add any constructor code after INITIALIZEComponent call //}
///
#REGION Windows Form Designer The code ///
/// summary> private (this.dataGrid1 = new system.windows.Forms.DataGrid (); this.button1 = new system.windows.Forms.Button (); this.table = new system. Windows.Forms.DataGridTableStyle (); this.stringcom = new System.Windows.Forms.DataGridTextBoxColumn (); this.boolcom = new System.Windows.Forms.DataGridBoolColumn (); this.button2 = new System.Windows.Forms.Button (); This.button3 = new system.windows.Forms.Button (); (this.DataGrid1)). BeginInit (); this.suspendlayout (); // // DataGrid1 // this.dataGrid1.DataMember = ""; this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGrid1.Location = new System.Drawing.Point (0, 8); this.dataGrid1.Name = "dataGrid1" Id = new system.drawing.size (288, 168); this.dataGrid1.tabindex = 0; this.dataGrid1.tablestyles.addrange (new system.windows.forms.DataGridtablestyle [] {this .Table}); // // Button1 // this.button1.location = new system.drawing.point (0, 192); this.button1.name = "button1"; this.button1.size = new system.drawing .Size (72, 40); this.button1.tabindex = 1; this.button1.text = "display"; this.button1.click = new system.eventhandler (this.button1_click); // // Table // this.table.DataGrid = this.dataGrid1; this.table.GridColumnStyles.AddRange (new System.Windows.Forms.DataGridColumnStyle [] {this.stringcom, this.boolcom}); this.table.HeaderForeColor = System.Drawing.SystemColors .ControlText;
THIS.TABLE.MAPPINGNAME = "ROCK"; // // Stringcom // this.stringcom.format = "" "; this.stringcom.formatinfo = null; this.Stringcom.Headertext =" column 1 "; this.Stringcom.mAppingname = "Band"; this.stringcom.nullText = ""; this.stringcom.width = 75; // // Boolcom // this.boolcom.falsevalue = "0"; this.boolcom.Headertext = "column 2"; This.boolcom.mappingname = "sog"; this.boolcom.nullText = ""; this.boolcom.nullvalue = "; this.boolcom.truevalue =" 1 "; this.boolcom.width = 75; //// Button2 // this.button2.location = new system.drawing.point (80, 192); this.button2.name = "button2"; this.button2.size = new system.drawing.size (72, 40); this .Button2.tabindex = 2; this.button2.text = "modification method 1"; this.button2.click = new system.eventhandler (this.button2_click); // // button3 // this.button3.Location = New System.drawing.point (168, 192); this.button3.name = "button3"; this.button3.size = new system.drawing.size (72, 40); this.butt ON3.TabINDEX = 3; this.button3.text = "Modification Method 2"; this.button3.click = new system.eventhandler (this.button3_click; // // Form1 // this.autoscalebasesize = new system.drawing .Size (6, 14); this.clientsize = new system.drawing.size (292, 273); this.Controls.add (this.button3); this.controls.add (this.button2); this.controls. Add (this.button1); this.Controls.add (this.DataGrid1); this.name = "form1"; this.text = "form1"; this.Load =
New system.eventhandler (this.form1_load); (this.DataGrid1)). endinit (); this.ResumeLayout (false);} #ENDREGION
///
Private void createDataTable () {dtable = new dataable ("rock");
// set columns name dtable.columns.add ("band", typeof (system.string)); DTABLE.COLUMNS.ADD ("SONG", TypeOf (System.String)); DTABLE.COLUMNS.ADD ("Album" , TypeOf (System.String));
// Add rows DataRow DROW = DTABLE.NEWROW (); DROW ["Band"] = "Iron MAIDEN"; DROW ["SONG"] = "0"; drow ["album"] = "ed hunter"; DTABLE. Rows.Add (DROW);
DROW = DTABLE.NEWROW (); drow ["Band"] = "metallica"; drow ["Song"] = "1"; drow ["album"] = "metallica"; DTABLE.ROWS.ADD (DROW); DROW = DTABLE.NEWROW (); drow ["band"] = "jethro tull"; drow ["Song"] = "0"; drow ["album"] = "Aqualung"; DTable.Rows.Add (DROW) ; DROW = DTABLE.NEWROW (); drow ["band"] = "mr. Big"; drow ["Song"] = "1"; drow ["album"] = "japandemonium"; DTABLE.ROWS.ADD ( DROW);
Private void createDataBLE2 () {dtable = new dataable ("rock");
// set columns name dtable.columns.add ("band", typeof (system.string)); DTABLE.COLUMNS.ADD ("SONG", TypeOf (System.String)); DTABLE.COLUMNS.ADD ("Album" , TypeOf (System.String));
// Add rows DataRow DROW = DTABLE.NEWROW (); DROW ["Band"] = "Iron MAIDEN"; DROW ["Song"] = "1"; drow ["album"] = "ed hunter"; DTABLE. Rows.add (drow); drow = dtable.newrow (); drow ["band"] = "metallica"; drow ["Song"] = "1"; drow ["album"] = "metallica"; DTABLE. Rows.add (drow); DROW = DTABLE.NEWROW (); drow ["band"] = "jethro tull"; drow ["song"] = "1"; drow ["album"] = "Aqualung"; DTABLE .ROWS.ADD (DROW); DROW = DTABLE.NEWROW (); drow ["Band"] = "mr. Big"; drow ["Song"] = "1"; drow ["album"] = "japandemonium" DTABLE.ROWS.ADD (DROW);
Private void form1_load (Object sender, system.eventargs e) {createDataTable ();
Private void button1_click (Object sender, system.eventargs e) {
this.dataGrid1.datasource = DTABLE.DEFAULTVIEW;
Private void button2_click (object sender, system.eventargs e) {createDataBLE2 (); this.DataGrid1.datasource = DTABLE.DEFAULTVIEW;}
Private void button3_click (object sender, system.eventargs e) {if (this.DataGrid1 [0,1] .tostring () == "1") {this.DataGrid1 [0, 1] = false;} else {THIS. DataGrid1 [0,1] = true;
}}}}