首页 > 代码库 > c# WinForm 编程总结
c# WinForm 编程总结
1、清空DataGridView
1 /// <summary> 2 /// 清空DataGridView 3 /// </summary> 4 /// <param name="dg">DataGridView</param> 5 public void ClearDataGridView(DataGridView dg) 6 { 7 try 8 { 9 if (dg == null || dg.DataSource == null)10 {11 return;12 }13 14 DataTable dt = (DataTable)dg.DataSource;15 16 dt.Rows.Clear();17 18 dg.DataSource = dt;19 20 }21 catch (Exception e)22 {23 string errorMsg = string.Format(@"清除{0} DataGridView数据时出错,错误原因:{1}", dg.Name, e.Message);24 25 Platform.Log(LogLevel.Fatal, errorMsg);26 27 AlifMessageBoxShowError(errorMsg);28 }29 }
2、清空C1FlexGrid
1 /// <summary> 2 /// 清空C1FlexGrid 3 /// </summary> 4 /// <param name="c1FG">C1FlexGrid</param> 5 public void ClearC1FlexGrid(C1.Win.C1FlexGrid.C1FlexGrid c1FG) 6 { 7 try 8 { 9 if (c1FG != null)10 {11 c1FG.Clear(C1.Win.C1FlexGrid.ClearFlags.Content);12 }13 }14 catch (Exception e)15 {16 string errorMsg = string.Format(@"清空{0} C1.Win.C1FlexGrid.C1FlexGrid数据时出错,错误原因:{1}", c1FG.Name, e.Message);17 18 Platform.Log(LogLevel.Fatal, errorMsg);19 20 AlifMessageBoxShowError(errorMsg);21 }22 }
c# WinForm 编程总结
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。