WinForm tableLayoutPanel error message

rfresh

Active member
Joined
Aug 23, 2012
Messages
26
Programming Experience
1-3
I'm trying to programmatic ally change one of the row SizeType properties on my tableLayoutPanel component.

I'm getting the following error:
System.Windows.Forms.TableLayoutRowStyleCollection' does not contain a definition for 'SizeType'

on the .SizeType in line 2 below.

I have this declared at the top of my form:
using System.Windows.Forms.Layout;

I'm not sure what I am still missing?

Thanks for any help.

C#:
        private void label2_Click(object sender, EventArgs e)
        {
1            TableLayoutRowStyleCollection styles = this.tableLayoutPanel.RowStyles;
2            styles.SizeType = SizeType.Absolute;
        }
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,136
Location
Sydney, Australia
Programming Experience
10+
Think about it. Let's say that you have a list of people all wearing read shirts. If you want one of those people to wear a blue shirt, do you put a blue shirt on the list? Of course not. You use the list to get the person and then you put the blue shirt on them. This is the same. That RowStyles property is a collection of RowStyle objects. You have to get the RowStyle object you want to change from the collection, then set the SizeType of that object.
 
Top Bottom