R4R
Right Place For Right Person TM
 
R4R C#C# TutorialsTable Layout Panel
previous

Home

Next

Table Layout Panel

The TableLayoutPanel control is a container control where child controls are added within a table structure. Each cell in the table contains a single control, unless a container such as a Panel is added first.

Useful properties

CellBorderStyle - This property determines if the cell is outlined with a border or not. A value from the TableLayoutPanelCellBorderStyle enumeration is required, the default value is None:
            Inset - A single-line sunken border.
            InsetDouble - A double-line sunken border.
            None - No borders.
            Outset - A single-line raised border.
            Outset Double - A double-line raised border.
            OutsetPartial - A single-line border containing a raised portion.
            Single - A single-line border.

ColumnCount - Determines the number of columns in the table.

ColumnStyles - A collection of column styles, one for each column in the TableLayoutPanel control.

Controls - Gets the collection of controls contained within the control.

GrowStyle - Determines whether the control should expand to accommodate new cells when all existing cells are occupied. A value from the TableLayoutPanelGrowStyle enumeration is required, the default value is AddRows:

  • AddColumns - The TableLayoutPanel gains additional columns after it is full.
  • AddRows - The TableLayoutPanel gains additional rows after it is full.
  • FixedSize - The TableLayoutPanel does not allow additional rows or columns after it is full.
  • RowCount - Determines the number of rows in the table.
  • RowStyles - A collection of row styles, one for each row in the TableLayoutPanel control.

Example

 

  

This dialog allows you to edit the SizeType property of each of the Columns and Rows in the TableLayoutPanel. The SizeType property determines how the Height (RowStyle) or Width (ColumnStyle) should be interpreted. A value from the SizeType enumeration is required, the default value is Percent:

  • Absolute - The row or column should be sized to an exact number of pixels.
  • AutoSize - The row or column should be automatically sized to share space with its peers.
  • Percent - The row or column should be sized as a percentage of the parent container.

Adding a TableLayoutPanel manually
 


// Create TableLayoutPanel
TableLayoutPanel tlp = new TableLayoutPanel();
 
// Set the BorderStyle to Inset
tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
 
// Grid has two columns
tlp.ColumnCount = 2;
 
// Grid has two rows
tlp.RowCount = 2;
 
// If grid is full add extra cells by adding column
tlp.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;
 
// Padding (pixels)within each cell (left, top, right, bottom)
tlp.Padding = new Padding(1, 1, 4, 5);
 
// Add TableLayoutPanel to the Forms controls
this.Controls.Add(tlp);

Adding controls manually

Adding a control to a TableLayoutPanel at run time can be done in a couple of ways. Simply using the Add method with just the name of the control adds the control to the first available cell.


// Create buttons
Button button1 = new Button();
button1.Text = "Click Me";
 
// Add buttons to TableLayoutPanel
tlp.Controls.Add(button1);

                 

previous

Home

Next


Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

10:New Updates
Tutorials,examples and Interview Questions with answers
Posted By: Shashi     Posted Date:02.10.14

9:C# Tutorials,C# examples and C# Interview Questions with answers
R4R provide C# Tutorials,C# examples and C# Interview Questions with answers. Through R4R you can develop a small application and small programs.We cover C# Tutorials,C# examples and C# Interview Questions and answers for freshers as well experienced programmer.
Posted By: Shashi     Posted Date:11.17.13

8:Java/J2EE(Servlet,JSP,JNDI,Struts,Spring,Hibernate,EJB,JSF,JMS,Web-Services)
In this section R4R covers Java/J2EE(Servlet,JSP, JNDI, Struts, Spring, Hibernate, EJB,JSF,JMS,Web-Services) Tutorials with Examples.R4R provide Java/J2EE (Servlet,JSP, JNDI,Struts, Spring, Hibernate, EJB, JSF, JMS, Web-Services) Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.13.13

7:CoreJava Tutorials , CoreJava Examples and CoreJava Interview Questions with answers
In this section R4R covers CoreJava Tutorials with CoreJava Examples. R4R covers CoreJava programming concept in easy way. R4R provide CoreJava Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.04.13

6:Microsoft.net Technology ASP.NET,c# ,ADO.NET,WCF,WPF,Silverlight ,VB.net
R4R provides Microsoft Technologies(like ASP.NET,c# ,ADO.NET,WCF,WPF, Silverlight and VB.ne)Tutorials with Examples,programming concept and Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.04.13

5:J2me Tutorials concept with Examples with Netbean IDE and J2ME Application Examples.
R4R cover basic J2me Tutorials concept with Examples and provide a way to develop J2me programming concept in easy way. R4R provide J2me Interview Questions with answers.R4R provide J2me Languages study materials with examples uing Netbean IDE and J2ME Application Examples.
Posted By: Shashi     Posted Date:10.30.13

4:J2me Tutorials concept with Examples ith netbean IDE and J2ME Application Examples.
R4R cover basic J2me Tutorials concept with Examples and provide a way to develop J2me programming concept in easy way. R4R provide J2me Interview Questions with answers.R4R provide J2me Languages study materials with examples uing Netbean IDE and J2ME Application Examples.
Posted By: Shashi     Posted Date:10.30.13

3:Java ebooks , Java tutorials , Java examples , Java interview questions and answers
R4R provides study materials for Java/j2EE technologies. R4R covers core java, advanced java, servlet, JSP, Struts, Spring, Hibernate, EJB, JSF, J2ME, ANT, JUnit and Some APIS .R4R also provides ebooks,tutorials,examples, interview questions and answers.
Posted By: Shashi     Posted Date:10.30.13

2:Learn basic C++ Tutorials with Examples , C++ Interview Questions with answers
R4R is a free E-learning website.You can learn basic C++ Tutorials with Examples , C++ Interview Questions with answers and also some hot topics.
Posted By: Shashi     Posted Date:10.30.13

1:C Tutorials with Example C subjective and objective interview questions and answers
R4R provide C Tutorials with Example and also provides C subjective and objective interview questions and answers.You can learn C in easy way.We cover basics of C here and give some examples.
Posted By: Shashi     Posted Date:10.30.13

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R