下列程序達(dá)到如下功能: 1、在表格中增加一個(gè)下拉菜單; 2、在表格中增加一個(gè)選擇菜單; 3、可以自己定制菜單的背景顏色; 在你的Page_Load 事件中加入如下代碼:
DropDownList dropDownLst = new DropDownList(); TableRow row = new TableRow(); dropDownLst.Items.Add("Item1"); dropDownLst.Items.Add("Item2"); dropDownLst.Items.Add("Item3"); dropDownLst.Items.Add("Item4"); dropDownLst.Items.Add("Item5"); dropDownLst.BackColor = System.Drawing.Color.Red; TableCell cell = new TableCell(); cell.Controls.Add(dropDownLst); row.Cells.Add(cell); row.BackColor = System.Drawing.Color.Green; Table1.Rows.Add(row);
CheckBox checkBox1 = new CheckBox(); checkBox1.Checked = true; checkBox1.BackColor = System.Drawing.Color.Yellow; TableCell cell2 = new TableCell(); cell2.Controls.Add(checkBox1); row.Cells.Add(cel
|