Bind OLEDBDataAdapter to the DataGrid under WinForm, this statement is a bit strange: you may want to see it, I have used it to write it in the evening, and I don't want everyone to think.
Of course, there is such a binding method, then we can also inherit the DataGrid binding SqlDataAdapter. You may try a try, and if you don't write, you will take the jade.
Related Attributes and Events:
CustomDataGrid instantiate a new CustomDataGrid controls for OleDB CustomDataGrid CustomDataGrid instantiating a new control for OleDB DataGridOleDbDataAdapter CustomDataGrid to control the assignment of new OleDbDataAdapter FillDataSetAndBindAfterBindOleDBDataAdapter CustomDataGrid BindOleDbDataAdapter whether new data DataBind CustomDataGrid passed after the new value of OleDBDataAdapter Binding Update Submit all Cancelupdate Abandon All Change Deleterows Delete All Selection (Delete does not affect the original data, if you need to update the database) EnableSelect does not allow multiple options (related to delete, related to interface) ConstructDataGridDisplayStyles created according to DataSet data type Data display mode addSelectRow adds new columns to select the title of the tabletittle attribute corresponding table
Using system.collections; using system.drawing; using system.data; using system.windows.form;
Namespace Forward.winui {///
// This is the OLEDBDATAADB.OLDBDATAADAPTER BINDB.OLDBDATAADAPTER BINDB.OLDBDATAADAPTER Bindo.oledbdataAdapter;
// This is the DataSet object, which is included in this DataGrid, private system.data.dataSet ContentDataSet;
// CustomDataGrid's BindoledBDataAdapter is incorporated in the new value to display new data private bool fillafterbindadp;
// Allow multi-line selection private bool enablemultiselectriselect;
// Each column name private string [] title, ///
// Todo: Add any initialization after InitializationComponent call} ///
// Todo: Add any initialization bindoledbadp = this.DataGridoledbdataadapter;} in the initializationComponent call.
///
#Region Component Designer Generated Code ///
CustomDataGrid #region to control the assignment of new OleDbDataAdapter ///
} #Endregion
#region FillDataSetAndBindAfterBindOleDBDataAdapter CustomDataGrid BindOleDbDataAdapter whether the new data ///
#region DataBind CustomDataGrid OleDBDataAdapter bound to the ///
BindoledBDataAdapter.Update ((System.Data.DataTable);} catch (system.exception ex) {messagebox.show (this, ex. amount ,.toString ());
} Finally {
}}}} #ENDREGION
#Region Cancelupdate Abandon All Change ///
#Region Delete Delete All Selection Item ///
INT i = 0; BOOL [] Row; Row = New Bool [(System.Data.DataTable) this.datasource) .Rows.count]; Foreach (DataRow Dr in ((System.Data.DataTable) this.DataSource .ROWS) {IF (DR ["SELECT"])) {row [i] = true;} else {row [i] = false;} i ;}
For (i = (system.data.dataable) this.datasource) .Rows.count-1; i> = 0; I ---) {if (convert.toboolean (row [i])) {((System. Data.DataTable) .datasource) .rows [i] .delete (); // ((System.Data.DataTable) this.datasource) .Rows.removeat (i);}}}}
} #Endregion
#REGION EnableSelect Do you allow multiple options (related to deletion {Return enablemultiselectriselect;} set {enablemultiselectr = value;}} #ENDREGON
#REGON CONSTRUCTDATAGRIDDISPLAYSTYLES Create data display mode ///
INT count; int currcount = 0;
IF (enablemultiselect) {count = this.contentDataSet.Tables [0] .COLUMNS.COUNT 1;} else {count = this.contentDataSet.tables [0] .columns.count;
EnableMultiselect) {addselectrow ();
Tempdgcs = new system.windows.Forms.DataGridColumnStyle [count];
if (EnableMultiSelect) {tempDGCS [0] = new System.Windows.Forms.DataGridBoolColumn (); tempDGCS [0] .HeaderText = "Select"; tempDGCS [0] .Width = 80;} foreach (DataColumn dc in this.ContentDataSet .Tables [0] .Columns) {switch (dc.DataType.ToString ()) {case "System.Boolean": tempDGCS [currCount] = new System.Windows.Forms.DataGridBoolColumn (); tempDGCS [currCount] .MappingName = dc.ColumnName; break; default: tempDGCS [currCount] = new System.Windows.Forms.DataGridTextBoxColumn (); tempDGCS [currCount] .MappingName = dc.ColumnName; break;} currCount ;}
System.windows.Forms.DataGridtableStyle Tempdgts = New DataGridTableStyle ();
// This is used to join the new column IF (TEMPDGTS.GRIDCOLUMNSTYLES.ADD (Tempdgcs [count-1]) for doing the selection;} int J; j = 0; if (this.enableMultiselect) { J = count-1;} else {j = count;}
For (int i = 0; i
THIS.TABLESTYLES.CLEAR (); tempdgts.mappingname = this.contentDataSet.Tables [0] .tablename; THIS.TABLESTYLES.ADD (TEMPDGTS); tempdgts.dispose ();}} #ENDREGION
///
Welcome to advice, thank you!