向表格布局面板中的单元格添加不同的颜色 [英] adding different colors to cells in tablelayout panel

查看:102
本文介绍了向表格布局面板中的单元格添加不同的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们....

如何将背景色添加到表格布局面板的单元格中.
实际上我想为不同的单元格添加不同的颜色...

有什么用吗....请给我建议...

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 from System.Windows.Forms.TableLayoutPanel and override System.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 type System.Windows.Forms.Panel so each cell contains an instance of Panel. 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 (use System.Windows.Forms.DockStyle.Fill with Padding). The panels used as pads for other controls can use different background colors.

—SA


这篇关于向表格布局面板中的单元格添加不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆