我需要编写一个函数,它将TableLayoutPanel在运行程序期间根据某些条件设置单元格中的颜色.
TableLayoutPanel除以16x16.程序开始时有一些条件.如果细胞的条件为真,则此销售必须涂成蓝色.例如:
private void start_Click(object sender, EventArgs e)
{
foreach (string str in some_list)
{
if (some condition)
{
set_color_in_cell at row[i] colum[j] //(what shoud i use here?)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我找到了这样的例子:
private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
{
if (e.Row == 0 && e.Column == 1)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Black), e.CellBounds);
}
}
Run Code Online (Sandbox Code Playgroud)
但我不明白如何使用它.如果有人知道这个,请帮助我.
private void start_Click(object sender, EventArgs e)
{
string SyncAnswer = "";
foreach (string file_string in Data_from_file)
{
COM_Port.WriteLine(file_string);
while (SyncAnswer != "READY")
{ …Run Code Online (Sandbox Code Playgroud)