Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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
Posted
Updated 2-Dec-11 17:16pm
v2

C#
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;
        }
    }
}


Code Translation for .NET (C#<->VB.NET)[^]
Convert VB.NET to C#[^]
 
Share this answer
 
Comments
srinivasan_indian 2-Dec-11 22:35pm    
thanks.. Do u have any idea about this?

private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e) { try

{ if (resizing) { if (rbColumn.Checked) {

columnStyles[GColumn].SizeType = SizeType.Absolute;

columnStyles[GColumn].Width += e.X - columnStyles[GColumn].Width; } else {

rowStyles[GRow].SizeType = SizeType.Absolute;

rowStyles[GRow].Height += e.Y - rowStyles[GRow].Height; } } }
catch (Exception ex)
{ //MessageBox.Show(ex.ToString());
} }

I used this code to resize the column dynamically. But its moving the particular column with the help of GColumn value as well as the next columns. Want to move only the specific column.. Help me..
Goto http://codeconverter.sharpdevelop.net/SnippetConverter.aspx
 
Share this answer
 
You can use following tool to convert your vb code to C# and vice versa.

http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900