本文介绍了如何隐藏vb.net中包含空值的datagridview行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 您好我希望找到一种方法来隐藏我的datagridview的某些行,如果它们不包含任何内容或null。我的datagridview绑定到一个excel工作表的数据源。我希望在导入时可以隐藏空行并仅显示包含值的行。我觉得这样的东西会起作用,但我最近没有运气。 Dim 空作为 布尔 = True 对于 i 作为 整数 = 0 要 dataGridView1.Rows.Count - 1 空= True 对于 j 作为 整数 = 0 dataGridView1.Columns.Count - 1 如果 dataGridView1.Rows(i).Cells(j).Value IsNot Nothing AndAlso dataGridView1 .Rows(i).Cells(j).Value.ToString()<> 然后 清空= 错误 退出 对于 结束 如果 下一步 如果空那么 dataGridView1.Rows.RemoveAt(i) 结束 如果 下一步 如果有人能就此事提出任何建议或帮助,我将不胜感激!解决方案 Hi I'm hoping to find a way to hide certain rows of my datagridview if they contain nothing or null. My datagridview is bound to a datasource that is an excel worksheet. I'm hoping on import that I can hide the rows that are empty and display only those that contain values. I'm thiking something like this will work but I've had no luck as of late. Dim Empty As Boolean = TrueFor i As Integer = 0 To dataGridView1.Rows.Count - 1 Empty = True For j As Integer = 0 To dataGridView1.Columns.Count - 1 If dataGridView1.Rows(i).Cells(j).Value IsNot Nothing AndAlso dataGridView1.Rows(i).Cells(j).Value.ToString() <> "" Then Empty = False Exit For End If Next If Empty Then dataGridView1.Rows.RemoveAt(i) End IfNextIf anyone can give any suggestions or help on the matter I would greatly appreciate it! 解决方案 这篇关于如何隐藏vb.net中包含空值的datagridview行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 14:08