sta*_*e12 -1 c# vb.net datagridview
您好我在网上找到了这个代码,它似乎做了我想要的.不过它是用c#写的,我不熟悉.任何多语言程序员都可以将其转换为vb.net?非常感谢您给予的任何帮助!
foreach (DataGridViewColumn clm in grdView.Columns)
{
Bool FoundData = false;
foreach (DataGridViewRow row in grdView.Rows)
{
if (row.Cells[clm.Index].Value.ToString() != string.Empty)
{
FoundData = true;
break;
}
}
if (!FoundData)
{
grdView.Columns[clm.Index].Visible = false;
}
}
Run Code Online (Sandbox Code Playgroud)
试试这个:
For Each clm As DataGridViewColumn In grdView.Columns
Dim FoundData As Boolean = False
For Each row As DataGridViewRow In grdView.Rows
If row.Cells(clm.Index).Value.ToString() <> String.Empty Then
FoundData = True
Exit For
End If
Next
If Not FoundData Then
grdView.Columns(clm.Index).Visible = False
End If
Next
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |