表格布局面板问题 [英] Table Layout Panel problem

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

问题描述

我正在为表格布局面板中的单元格动态添加标签。只显示标签的轮廓(不是它们的文字或背景颜色)。



以下是格式化表格布局面板并添加标签的例程的核心:



tlp.Controls.Clear();

tlp.SuspendLayout();







int [] columnWidths = GetWidthOfColumns(tlp,nList,maxColWidth);

FormatColNRow(tlp, nList [0] .Height,maxRow,columnWidths);

PutNodesInGrid(tlp,nList,columnWidths);







tlp.ResumeLayout();

tlp.Refresh();

tlp.Focus();



以下是实际将标签添加到表格布局面板的方法中的代码行:



tlp.Controls.Add(n);

tlp.SetCellPosition(n,n ew TableLayoutPanelCellPosition(n.ContainerColumn,n .ContainerRow));





表格布局面板的形式(不是任何其他形式)容器)。标签显示在正确的单元格中并且尺寸正确,但每个标签的文字和背景颜色都没有显示。



有关检查内容的任何建议找到这个问题的根源?

I am dynamically adding labels to cells in a table layout panel. Only the outlines of the labels are showing (not their text or background color).

Here is the heart of the routine that formats the table layout panel and adds the labels:

tlp.Controls.Clear();
tlp.SuspendLayout();
.
.
.
int[] columnWidths = GetWidthOfColumns(tlp, nList, maxColWidth);
FormatColNRow(tlp, nList[0].Height, maxRow, columnWidths);
PutNodesInGrid(tlp, nList, columnWidths);
.
.
.
tlp.ResumeLayout();
tlp.Refresh();
tlp.Focus();

Here are the lines of code from the method that actually adds the labels to the table layout panel:

tlp.Controls.Add(n);
tlp.SetCellPosition(n, new TableLayoutPanelCellPosition(n.ContainerColumn, n.ContainerRow));


The table layout panel is in the form (not in any other container). The labels are showing in the correct cell and with the correct size, but the text and background color of each label is not showing.

Any suggestions as to what to check to find the source of this problem?

推荐答案

这个问题经常发生,因为你没有设置标签的'BackColor属性,也没有设置'的文本属性标签。



因此,Label采用其Form / ContainerControl的BackColor,并且没有Text,即使它在那里也看不见。



Rx:设置标签'文本属性,或确保BackColor与其Form / ContainerControl的BackColor足够不同,以便清晰可见。
This problem usually occurs because you have not set the 'BackColor Property of the Label, and not set the 'Text Property of the Label.

So, the Label takes the BackColor of its Form/ContainerControl, and, having no Text, it appears invisible even though it's there.

Rx: Set the Label 'Text Property, or make sure the BackColor is different enough from the BackColor of its Form/ContainerControl to be distinctly visible.


这篇关于表格布局面板问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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