• 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         }
    人生,总是有一些空城旧事,年华未央;总是有些季节,一季花凉,满地忧伤。许多事,看开了,便会峰回路转;许多梦,看淡了,便会云开日出。学会思索,学会珍藏,微笑领悟,默默坚强。
  • 相关阅读:
    hybrid项目h5页路由回退问题解决
    各个端类型判断
    图片展示方法总结
    微信小程序简易table组件实现
    微信小程序动画技巧
    git常用命令
    小程序跳转
    excel日期插件
    excel省市区三级分类级联
    mysql字符串分割操作
  • 原文地址:https://www.cnblogs.com/yuzhou133/p/4157009.html
Copyright © 2020-2023  润新知