tablelayoutpanel中特定单元格的背景色 [英] Backcolor for a particular cell in tablelayoutpanel

查看:113
本文介绍了tablelayoutpanel中特定单元格的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时为tablelayoutpanel中的特定单元格设置背景色?如果用户单击特定的单元格,则该单元格应显示一些颜色.使用户知道选择了特定的单元格.这应该动态完成..

不需要选择整个行或列,只需选择特定的单元格...

How to set backcolor for a particular cell in a tablelayoutpanel during runtime? If the user clicks particular cell, that cell should show some color. So that user know that the particular cell is selected. This should be done dynamically..

Dont need to selected entire row or column,only particular cell...

How can I achieve this?

推荐答案

以下内容会将单元格的背景颜色设置为1、1到棕色:


The following will set the background color of the cell at 1, 1 to brown:


private void tableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e) {
       if (e.Column == 1 && e.Row == 1) {
           e.Graphics.FillRectangle(Brushes.brown, e.CellBounds);
       }
   }


检查这些

TableLayoutPanel-手动编辑列和行样式 [单击TableLayoutPanel中的特定单元格 [
Check these

TableLayoutPanel - Editing Column and Row Styles manually[^]
Clicking a Specific Cell in a TableLayoutPanel[^]


这篇关于tablelayoutpanel中特定单元格的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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