我有9X6 tableLayoutPanel,我用下面的代码填充一些单元格。我需要的是有时在一个单元格内必须有两个标签。我怎么能这样做?
void time(String s) {
//... some algorithm for my code to work
for (int i = 0; i < numberPart.Length; i++)
{
number[i] = numberPart[i].ToString(); ;
}
for (int i = 0; i < text.Length; i++)
{
int j = Convert.ToInt32(number[i]);
if (text[i] == "AA")
{
// since i create Panel p everytime i think it just stores the label1 that I put right below and the old one just doesnt display.
// what i want is simply inside one cell
/////////
label1
label2
/////////
Panel p = new Panel();
Label label1 = new Label();
label1.Text = dataGridView1.SelectedCells[0].Value.ToString();
label1.AutoSize = false;
label1.Height = p.Height;
p.Dock = DockStyle.Fill;
p.Controls.Add(label1);
tableLayoutPanel1.Controls.Add(p,j,1);
}
}
在按钮点击事件中调用时间(String s)。所以简单地说,每当我点击按钮时,数据被拉出并作为文本插入标签。所以我不能在这里添加第二个标签,这将是毫无意义的。在确切的单元格内部将有2个标签甚至不是%100。