DataGrid refresh

xiaoxiao2021-03-06  40

Public Class ClassDataGridRefresh {public classdataGridrefresh () {}

#Region DataGrid Refresh

///

/// DataGrid refresh /// /// DataGrid control /// DataView data source < / param> /// All listed width, use a semicolon ";" separated /// hidden column, use semicolon ";" partition public static void RefreshDataGrid (System.Windows.Forms.DataGrid DG, System.Data.DataView DV, string m_strWidth, string m_strHidden) {try {RefreshDataGrid (DG, DV, m_strWidth, m_strHidden, true);} catch (Exception ex) {system.windows.Forms.MessageBox.show (ex.Message.toString (), "DataGrid refresh error");}}

///

/// DataGrid refresh /// /// DataGrid control /// DataView data source < / param> /// All listed width, use a semicolon ";" separated /// hidden column, use semicolon ";" Separate /// Whether to re-refresh each time the list public static void refreshDataGrid (System.Windows.Forms.DataView DV, STRING m_strWidth, string m_strHidden, bool m_blnIsReDraw) {try {int i; int numCols; System.Windows.Forms.DataGridTableStyle ts = new System.Windows.Forms.DataGridTableStyle (); // datagrid that it determines what System. Windows.Forms.DataGridTextBoxColumn AcolumnTextColumn; // To rewrite the stuff to System.Windows.Forms.DataGridBoolColumn AcolumnBoolColumn; // To rewrite Dongdong

String [] columnWidths = m_strwidth.split (';'); string [] strhiddens = m_strhidden.split (';'); Numcols = DV.TABLE.COLUMNS.COUNT;

if (m_blnIsReDraw == true) {foreach (string strHiddenTemp in strHiddens) {if (strHiddenTemp.Length> 0) {DV.Table.Columns [strHiddenTemp] .ColumnMapping = System.Data.MappingType.Hidden;}}

Dg.font = new system.drawing.font ("Song", 10, System.drawing.FontStyle.regular;

DG.DataSource = DV;

IF (m_blnisredraw == true) {ts.mappingname = DV.TABLE.TABLENAME;

For (i = 0; i

IF (ColumnWidths.Length> i) {acolumnBoolColumn.width = (int) (ColumnWidths [i]) * 50);}

Ts.GridColumnStyles.Add (acolumnBoolColumn); // Add a custom Column style

Break;

default: // Default (Text) Column aColumnTextColumn = new System.Windows.Forms.DataGridTextBoxColumn (); // To change the column header name, change the value of the sentence HeaderText aColumnTextColumn.HeaderText = DV.Table.Columns [i]. ColumnName; acolumntextColumn.mappingname = DV.TABLE.COLUMNS [i] .columnname;

IF (ColumnWidths.Length> i) {acolumnTextColumn.width = (int) (columnwidths [i]) * 50);}

Ts.GridColumnStyles.add (acolumntextColumn); // Add a custom Column style break;}} DG.TABLESTYLES.CLEAR (); DG.TABLESTYLES.ADD (TS);}} catch (exception ex) {system. Windows.Forms.MessageBox.show (ex.Message.toString (), "DataGrid Refresh Error");}} #ENDREGION

}

转载请注明原文地址:https://www.9cbs.com/read-78858.html

New Post(0)