如何对datagridview中的数据进行查找 我想在对datagridview中的数据进行查找,屏蔽一些内容,不涉及数据源操作,应该怎么写?本人小白,望各位大哥大姐多多指教!!(winform窗体) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 根据行及列的信息可以设置row的visible=false 我不是很懂你的意思,如果你只是想隐藏gridview中那一行的信息public void GridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[1].Visible = false;//隐藏第一行的表头 } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Visible = false;//隐藏第一行的数据行 } }表头和数据行都要隐藏掉,才隐藏一列的信息,,这里的 1 代表隐藏第1列的信息,1是可以改动的,可以改到你想要隐藏的那一列,希望能对你有所帮助。 重新配置数据源,在数据源的datatable里筛选dt.Select("商品<>苹果"); 代码 foreach( DataGridViewRow rows in dataGridView.Rows )//如果DataGridView中有空的数据,则提示数据输入不完整并退出添加,这里的rows包括标题行{ foreach( object cell in rows.Cells ) { DataGridViewCell d= (DataGridViewCell) cell; if( d.Value==你要屏蔽的数据 ) { 单元格的visible=false ; return; } }}不包括标题行代码 for( int i=0 ; i<dataGridView.Rows.Count-1 ; i++ )//如果DataGridView中有空的数据,则提示数据输入不完整并退出添加,不包括标题行{ foreach( object cell in dataGridView专家模式.Rows[i].Cells ) { DataGridViewCell d= (DataGridViewCell) cell; if( d.Value==null ) { 单元格的visible=false ; return; } }} 一样的,筛选,判断第一列中有没有你出现你要屏蔽的数据,如果有就等于空if (e.Row.RowType == DataControlRowType.DataRow) { if(e.Row.Cells[1].Text=="你要屏蔽的数据") { e.Row.Cells[1].Text=""; } } C# 使用My 命名空间 出错 问个字符串处理的问题!!!!!!!!!!!!!1 winform程序运行时 焦点突然就失去了 下面的代码有没有什么简单的形式? C# 利用输入法的句柄拿到输入的内容列表或者自定输入法文字列表面板使它成为程序的一部分(C# directX 游戏开发) 菜鸟向高人求教!请不吝赐教啊! 水晶报表问题 关于C#调用MSSQLServer的存储过程的问题! datagrid如何实现两列相加 showdialog 打开的 form 怎么返回值? 在VS2008设计界面的时候,怎么切换到父控件呢? 求助:DataGridView中如何获取一次性选择多行的行号?
public void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[1].Visible = false;//隐藏第一行的表头
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Visible = false;//隐藏第一行的数据行
}
}表头和数据行都要隐藏掉,才隐藏一列的信息,,这里的 1 代表隐藏第1列的信息,1是可以改动的,可以改到你想要隐藏的那一列,希望能对你有所帮助。
代码 foreach( DataGridViewRow rows in dataGridView.Rows )//如果DataGridView中有空的数据,则提示数据输入不完整并退出添加,这里的rows包括标题行
{
foreach( object cell in rows.Cells )
{
DataGridViewCell d= (DataGridViewCell) cell;
if( d.Value==你要屏蔽的数据 )
{
单元格的visible=false ;
return;
}
}
}不包括标题行
代码 for( int i=0 ; i<dataGridView.Rows.Count-1 ; i++ )//如果DataGridView中有空的数据,则提示数据输入不完整并退出添加,不包括标题行
{
foreach( object cell in dataGridView专家模式.Rows[i].Cells )
{
DataGridViewCell d= (DataGridViewCell) cell;
if( d.Value==null )
{
单元格的visible=false ;
return;
}
}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.Cells[1].Text=="你要屏蔽的数据")
{
e.Row.Cells[1].Text="";
}
}