码迷,mamicode.com
首页 > Windows程序 > 详细

c# WinForm 编程总结

时间:2014-12-11 12:10:55      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:winform   datagridview   style   blog   io   ar   color   sp   for   

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 编程总结

标签:winform   datagridview   style   blog   io   ar   color   sp   for   

原文地址:http://www.cnblogs.com/yuzhou133/p/4157009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!