在 TableLayoutPanel 中隐藏两个组合单元格之间的边框 [英] Hide the border between two combined cells in TableLayoutPanel
问题描述
我有一张 4x4 的桌子.如何使第一行只有 2 个单元格?尝试使用 ColumnSpan
但它仍然在单元格之间绘制边界.
I have 4x4 table. How to make that the first row will have 2 cells only?
Tried with ColumnSpan
but it's still drawing borders between cells.
示例:
----------------------
| A | B |
----------------------
| 1 | 2 | 3 | 4|
----------------------
推荐答案
你可以在单元格中Dock
一个Panel
,Margin=0
然后将该 Panel
扩展到所需的大小,并将其用作单元格中对象的容器.
You can Dock
a Panel
with Margin=0
in a cell and then span that Panel
to the desired size and use it as the container of the objects in the cell.
或者,您可以将 Label
的 AutoSize
设置为 false
,然后将其 Dock
设置为 填充
,然后将该Label
扩展到所需的大小.
Alternatively, you can set AutoSize
of a Label
to false
and then set its Dock
to Fill
and then span that Label
to the desired size.
(面板显示为绿色,标签显示为黄色)
(The Panel is shown in Green, the Labels are shown in Yellow)
使用宽度为 2 像素(如插图)的边框时唯一的问题是它会使一个像素出现在顶部.使用 1 像素宽边框类型(如 Single)可以避免这种情况
The only problem when using borders with 2 pixels width (like inset) is it makes one pixel to appear at the top. This can be avoided using 1-pixel wide border type (like Single)
这篇关于在 TableLayoutPanel 中隐藏两个组合单元格之间的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!