Row/Column coloring for TableLayoutPanel (vs2008, winform)

前端 未结 2 1266
梦毁少年i
梦毁少年i 2021-01-12 00:03

Can i add particular color for entire Row or Column in TableLayoutPanel ? How ? please provide sample code if any ..

Thanks in adv.

2条回答
  •  耶瑟儿~
    2021-01-12 01:01

    I found this answer much easier to implement:

    This allowed me to put a full backcolor on my cell.

    1. Create a Panel, which has a backcolor, and
    2. I Dock that Panel in my TableLayoutPanel

    Then that TableLayoutPanel Cell has a backcolor.

    My Code ended up looking like this:

    Panel backgroundColorPanel = new Panel();
    backgroundColorPanel.BackColor = Color.FromArgb(243, 243, 243);
    backgroundColorPanel.Dock = DockStyle.Fill;
    backgroundColorPanel.Margin = new Padding(0);
    backgroundColorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left));
    backgroundColorPanel.AutoSize = true;
    backgroundColorPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    this.originalTableLayoutPanel.Controls.Add(backgroundColorPanel, 0, row);
    

    http://www.codeguru.com/forum/showthread.php?t=444944

提交回复
热议问题