1. Empty DataGridView
1 /// <summary>2 ///Empty DataGridView3 /// </summary>4 /// <param name= "DG" >DataGridView</param>5 Public voidCleardatagridview (DataGridView DG)6 {7 Try8 {9 if(DG = =NULL|| Dg. DataSource = =NULL)Ten { One return; A } - -DataTable dt =(DataTable) DG. DataSource; the - dt. Rows.clear (); - -Dg. DataSource =DT; + - } + Catch(Exception e) A { at stringErrorMsg =string. Format (@"Error occurred while clearing {0} datagridview data due to: {1}", DG. Name, e.message); - - Platform.Log (Loglevel.fatal, errormsg); - - Alifmessageboxshowerror (errormsg); - } in}
2. Empty C1flexgrid
1 /// <summary>2 ///Empty C1flexgrid3 /// </summary>4 /// <param name= "C1FG" >C1flexgrid</param>5 Public voidClearc1flexgrid (C1. Win.C1FlexGrid.C1FlexGrid C1FG)6 {7 Try8 {9 if(C1FG! =NULL)Ten { One C1fg.clear (C1. Win.C1FlexGrid.ClearFlags.Content); A } - } - Catch(Exception e) the { - stringErrorMsg =string. Format (@"empty {0} C1. Error Win.C1FlexGrid.C1FlexGrid data, cause: {1}", C1fg.name, e.message); - - Platform.Log (Loglevel.fatal, errormsg); + - Alifmessageboxshowerror (errormsg); + } A}
C # WinForm Programming summary