我对c#datagridview有疑问 [英] i have a question on c# datagridview

查看:72
本文介绍了我对c#datagridview有疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从c#.net(windows)中的datagridview清除某些列数据







thanksss

how to clear certain column data from datagridview in c#.net (windows)



thanksss

推荐答案

创建一个数据表并读取您想要的值并将其放入另一个表并将此表绑定到数据网格视图。



哪一列想要清空值然后把它放在其中任何值。



Create one data table and read the value which you want and put it another table and bind this table to data grid view.

which column want to empty value then put it any value in that.

DataTable dt = new DataTable();
DataRow Row  = dt.NewRow();
for (int f = 0; f < Cols; f++)
{
    Row[f] = Fields[f];
}
dt.Rows.Add(Row);


您可以简单地使用Loop清除DataGridView中的列值

You can simple use Loop to clear the column value from DataGridView
foreach (DataGridViewRow myRow in dataGridView1.Rows) 
{
    myRow.Cells[0].Value = null; // assuming you want to clear the first column
}


这篇关于我对c#datagridview有疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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