C# 如何将此c代码转换为vb.net?
您好,我在网上找到了这段代码,它似乎满足了我的要求。但是它是用我不熟悉的c语言写的。有没有能把它转换成vb.net的多语言程序员?我非常感谢你所给予的任何帮助C# 如何将此c代码转换为vb.net?,c#,vb.net,datagridview,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
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;
}
}
试试这个:
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
你可以使用任何在线转换工具
试试这个工具。您可能会发现它对以后的转换很有帮助:
请尝试转换器:+1以获得简单的答案。Bool不是有效的VB.NET类型。你把转换看得太字面了。它也不是一个有效的C类型-垃圾输入垃圾输出。
For Each clm As DataGridViewColumn In grdView.Columns
Dim FoundData As Bool = 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