Tablelayout面板 - 绘制外边框和单元格

时间:2016-10-20 10:59:38

标签: vb.net tablelayoutpanel

我的TableLayoutPanel中有3行,我想在它周围绘制边框:

enter image description here

我怎样才能做到这一点?

我尝试了这个,但它没有绘制第一行的外边框:

 If (e.Column = 0 And e.Row = 1) Then
            e.Graphics.DrawRectangle(New Pen(Color.FromArgb(94, 94, 94)), e.CellBounds)
        End If

此代码的输出为:

enter image description here

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

I believe the problem is in the e.Row = 1 part. Remember that the first row is index 0.

Try this:

If (e.Column = 0 And e.Row = 0) Then
    e.Graphics.DrawRectangle(New Pen(Color.FromArgb(94, 94, 94)), e.CellBounds)
End If