tableLayoutPanel使用方法

private   void  TJ( string  sql,  string  table)
        
{
            
this.tableLayoutPanel1.Controls.Clear()
            DataSet ddss 
= DataBase.DatasetCol(sql, table);
            
int SLsum = 0;
            
int JEsum = 0;
            
foreach (DataRow drr in ddss.Tables[table].Rows)
            
{
                
for (int i = 0; i < 4; i++)
                
{
                    Label lbi 
= new Label();
                    
this.tableLayoutPanel1.Controls.Add(lbi);
                    lbi.Text 
= drr[i].ToString();
                    lbi.ForeColor 
= System.Drawing.Color.Blue;

                }

                SLsum 
+= Convert.ToInt32(drr[1].ToString());
                JEsum 
+= Convert.ToInt32(drr[3].ToString());
            }

            
//合计;
            Label lbb1 = new Label();
            
this.tableLayoutPanel1.Controls.Add(lbb1);
            lbb1.ForeColor 
= System.Drawing.Color.Red;
            
this.tableLayoutPanel1.SetColumnSpan(lbb1, 4);
            lbb1.Width 
= 140;
            lbb1.Anchor 
= System.Windows.Forms.AnchorStyles.Right;
            lbb1.Text 
= "合计数量:" + SLsum.ToString();
            Label lbb2 
= new Label();
            
this.tableLayoutPanel1.Controls.Add(lbb2);
            lbb2.ForeColor 
= System.Drawing.Color.Red;
            
this.tableLayoutPanel1.SetColumnSpan(lbb2, 4);
            lbb2.Width 
= 140;
            lbb2.Anchor 
= System.Windows.Forms.AnchorStyles.Right;
            lbb2.Text 
= "合计金额:" + JEsum.ToString();
        }
 

你可能感兴趣的:(sql,table)