无法清除DataGridView中的List [英] Can't clear the List in DataGridView

查看:70
本文介绍了无法清除DataGridView中的List的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



无法使用MDI表单中的清除按钮清除gridview值:

  foreach (控制ct  in  cntr.Controls)
{
if (ct TextBox)
{
((TextBox)ct).Clear( );
}
else if (ct.HasChildren)
{
ClearFields(ct);
}
else if (ct ComboBox)
{
((ComboBox)ct).SelectedIndex = -1;
}
else if (ct RichTextBox)
{
((RichTextBox)ct).Clear();
}
else if (ct DataGridView)
{
((DataGridView)ct).Rows.Clear();
}
}

解决方案

试试这个

 datagridview1.Rows.Clear(); 


Dear Frnds,

can't clear the gridview values using clear button from MDI form:

foreach (Control ct in cntr.Controls)
           {
               if (ct is TextBox)
               {
                   ((TextBox)ct).Clear();
               }
               else if (ct.HasChildren)
               {
                   ClearFields(ct);
               }
               else if (ct is ComboBox)
               {
                   ((ComboBox)ct).SelectedIndex = -1;
               }
               else if (ct is RichTextBox)
               {
                   ((RichTextBox)ct).Clear();
               }
               else if (ct is DataGridView)
               {
                   ((DataGridView)ct).Rows.Clear();
               }
           }

解决方案

try this

datagridview1.Rows.Clear();


这篇关于无法清除DataGridView中的List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆