本文介绍了需要将此代码转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim VisColCount As Int16
For x As Long = 0 To Me.TableLayoutPanel1.ColumnCount - 1
If Me.TableLayoutPanel1.GetControlFromPosition(x, 0).Visible Then VisColCount += 1
Next
If VisColCount > 0 Then
For x As Long = 0 To Me.TableLayoutPanel1.ColumnCount - 1
With Me.TableLayoutPanel1.ColumnStyles(x)
If Me.TableLayoutPanel1.GetControlFromPosition(x, 0).Visible Then
.SizeType = SizeType.Percent
.Width = 100 / VisColCount
Else
.SizeType = SizeType.Absolute
.Width = 0
End If
End With
Next
End If
推荐答案
Int16 VisColCount;
for (long x = 0; (x
<= (this.TableLayoutPanel1.ColumnCount - 1)); x++) {
if (this.TableLayoutPanel1.GetControlFromPosition(x, 0).Visible) {
VisColCount++;
}
}
if ((VisColCount > 0)) {
for (long x = 0; (x
<= (this.TableLayoutPanel1.ColumnCount - 1)); x++) {
// With...
if (this.TableLayoutPanel1.GetControlFromPosition(x, 0).Visible) {
SizeType.Percent.Width = (100 / VisColCount);
this.TableLayoutPanel1.ColumnStyles(x).SizeType = (100 / VisColCount);
}
else {
SizeType.Absolute.Width = 0;
this.TableLayoutPanel1.ColumnStyles(x).SizeType = 0;
}
}
}
.NET(C#<-> VB.NET)的代码转换 [ ^ ]
将VB.NET转换为C# [ ^ ]
Code Translation for .NET (C#<->VB.NET)[^]
Convert VB.NET to C#[^]
这篇关于需要将此代码转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!