向表格布局面板中的单元格添加不同的颜色 [英] adding different colors to cells in tablelayout panel
本文介绍了向表格布局面板中的单元格添加不同的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们....
如何将背景色添加到表格布局面板的单元格中.
实际上我想为不同的单元格添加不同的颜色...
有什么用吗....请给我建议...
Hi frnds....
how to add the background color to the cells of the tabel layout panel..
actually i want to add different colors to different cells...
is there any property for that.. plz give me suggestion...
thanks in advance..
推荐答案
您可以创建一个从System.Windows.Forms.TableLayoutPanel
派生的类,并覆盖System.Windows.Forms.TableLayoutPanel.OnCellPaint
来为该单元格创建任何自定义外观.
在此处查看代码示例:
http://msdn.microsoft.com/en-us/library/system. windows.forms.tablelayoutpanel.aspx [ ^ ].
或者,您可以使类型为System.Windows.Forms.Panel
的arrange子控件,以便每个单元格包含一个Panel
实例.步骤(针对其他子控件,如按钮)在此处进行了描述: http://msdn.microsoft.com/en-us/library/w4yc3e8c(v=VS.90).aspx [
You can create a class derived fromSystem.Windows.Forms.TableLayoutPanel
and overrideSystem.Windows.Forms.TableLayoutPanel.OnCellPaint
to create any custom appearance for the cell.
See a code sample here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx[^].
Alternatively, you can make arrange child controls of the typeSystem.Windows.Forms.Panel
so each cell contains an instance ofPanel
. The steps (for other child controls like buttons) are described here: http://msdn.microsoft.com/en-us/library/w4yc3e8c(v=VS.90).aspx[^]. After you do it, arrange other controls as children of those panels (useSystem.Windows.Forms.DockStyle.Fill
withPadding
). The panels used as pads for other controls can use different background colors.
—SA
这篇关于向表格布局面板中的单元格添加不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文