Table 控制項使用樣本

來源:互聯網
上載者:User
 protected void Table_Create()
        {
            //------------------------------------------------------------------
            TableRow tr;  //定義的表格的行
            TableCell tc; //定義表格的列
            int TrNum = 15; //行數
            int TcNum = 5;//列數
            Literal Lie1;
            for (int n = 0; n < TrNum;n++ )
            {
                tr = new TableRow();
                for (int v = 0; v < TcNum;)
                {
                    tc = new TableCell();
                    Lie1 = new Literal();
                    tc.Width = Unit.Pixel(50);
                    Lie1.Text = "行" + n + "列" + v;
                    tc.Controls.Add(Lie1);
                    //tc.Controls.Add(new LiteralControl("行" + n + "列" + v));
                    tc.HorizontalAlign = HorizontalAlign.Center;
                    if(v%2==0)
                    {
                        tc.BackColor = Color.HotPink;
                    }
                    else
                    {
                        tc.BackColor = Color.Green;
                    }
                    tr.Cells.Add(tc);
                    tc.Attributes.Add("onclick", "alert('第" + n + "行" + ",第" + v + "列');");
                    v++;
                }
                Table2.Rows.Add(tr);
                if(n%2==0)
                {
                    tr.Attributes.Add("style", "page-break-after:always;BackColor:Back;");
                }
            }
           
            Table2.Width = Unit.Pixel(560);
            Table2.BorderWidth = Unit.Pixel(1);
            Table2.BorderStyle = BorderStyle.Ridge;
            //Table2.Attributes.Add("onclick","return confirm('是否繼續測試?');");
        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.