label.Attribute.Add( "width" , "200" );

解决方案 »

  1.   

    还有错误提示:Exception Details: System.MissingMemberException: Public member 'attribute' on type 'Label' not found.
      

  2.   

    label.Attributes["style"]="width:200px";
      

  3.   

    將label加入到固定的table td中。

    label.style="Width:200"
      

  4.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    Label lbl = new Label();
    lbl.BackColor = Color.Red;
    lbl.Width = 300;
    lbl.Text = "你好";
    this.Controls.Add(lbl);
    }
    //上面代码经测试,可用
      

  5.   


    ((Lable)Controls[""]).Width  = Unit.Pixel(160);