为了过滤空格或空格的数据表列,我使用了这个过滤器,但它不起作用
dt.DefaultView.RowFilter =
string.Format("[{0}] ='%{1}%'(string.IsNullOrWhiteSpace(dt.Columns[int.Parse(comboBox8.Text) - 1].ColumnName.ToString())),true);
答案 0 :(得分:0)
我通过以下方式解决: 1-使用这个有趣的
public static bool IsNullOrWhiteSpace(string value)
{
if (value != null)
{
for (int i = 0; i < value.Length; i++)
{
if (!char.IsWhiteSpace(value[i]))
{
return false;
}
}
}
return true;
}
然后我将此代码用于数据网格视图中的特定列: if((function.IsNullOrWhiteSpace(dataGridView3.Rows [j] .Cells [int.Parse(comboBox8.Text) - 1] .Value.ToString())== true)) dataGridView3.Rows [j] .Cells [int.Parse(comboBox8.Text) - 1] .Value =“Empty”;
然后我使用这个过滤器: dt.DefaultView.RowFilter = string.Format(“[{0}] not LIKE'%{1}%'”,dt.Columns [int.Parse(comboBox8.Text) - 1] .ColumnName,“Empty”);