如何使用TableLayoutPanel创建简单的调色板? [英] How to create a simple color palette using a TableLayoutPanel?

查看:74
本文介绍了如何使用TableLayoutPanel创建简单的调色板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个简单的绘图程序,并希望有一个WebSafe颜色的调色板可供选择。有没有一种简单的方法将颜色添加到TableLayoutPanel?我想的是:



对于WebSafe Colors中的每种颜色''它是System.Drawing.WebSafeColors吗?

TableLayoutPanel.cells .add(颜色)

下一页



我也想知道TableLayoutPanel的单元格,行和列是否与一个DataGridView?我是否可以单击一个单元格来选择它的颜色,还是我必须向单元格添加控件?我基本上只需要在15X15像素的方块中显示一个简单的色样,我可以点击切换笔的颜色。请帮助。

Hi, I have made a simple drawing program and would like to have a palette of the WebSafe colors to choose from. Is there a simple way to add the colors to a TableLayoutPanel? I was thinking something like:

For Each color in WebSafe Colors ''Would it be System.Drawing.WebSafeColors?
TableLayoutPanel.cells.add(color)
Next

I was also wondering if the TableLayoutPanel''s cells, rows and columns are created the same as a DataGridView? Would I be able to click on a cell to choose it''s color, or do I have to add controls to the cell? I basically just need to display a simple color swatch in a 15X15px square, that I can click to switch pen colors. Please help.

推荐答案

您不了解TableLayoutPanel是什么或它是如何工作的。它真的没有任何细胞。生活中唯一的目的是控制放置在其中的控件的布局和尺寸。没有像你在DataGridView或其他可视化控件中找到的属性。



为了得到你想要的东西,你必须在那些中添加类似标签的东西cells并将每个标签的背景颜色设置为您想要的颜色。
You''re not understanding what the TableLayoutPanel is or how it works. It really doesn''t have any "cells". It''s sole purpose in life is to control layout and sizing of controls placed within. There are no properties like you would find in a DataGridView or other visual control.

To get what you want, you''d have to put something like labels in those "cells" and set the backcolor of each label to the color you want.


这篇关于如何使用TableLayoutPanel创建简单的调色板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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