Never mind, I realised that the TableLayoutPanel's border setting was "Inset", so it appeared as though there was whitespace. Changing it to "Single" fixed the issue.
Highlight Row TableLayoutPanel
-
03-07-2022 - |
Question
I'm trying to make a row of a TableLayoutPanel appear as highlighted when the user selects a cell. The row contains, for example, a Label in one column and a TextBox in the other. I've got this so far (when adding a Label):
Label label = new Label();
label.Text = text;
label.BackColor = Color.Blue;
label.Dock = DockStyle.Fill;
label.Margin = new Padding(0);
label.Anchor = AnchorStyles.Top | AnchorStyles.Left;
table.Controls.Add(label, col, row);
This works well, except there is a bit of whitespace above and to the left of the label. Any idea how to make it so that the entire cell is coloured?
I know about cell painting, but I prefer the above-mentioned approach.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow