关于自动产生控件的位置问题?
在页面中有一个3行4列的表格,我需要根据用户的操作自动产生一个textbox控件并显示在表格第2行3列。表格是用html代码写的,不是asp.net的System.Web.UI.WebControls.Table控件,自动生成textbox我会,但是怎么控制生成控件在页面中的位置,希望有此经验的网友帮帮忙,谢谢! 问题点数:0、回复次数:5Top
1 楼dxphero(火鸟hero)回复于 2004-09-02 09:01:43 得分 0
你在页面中加一个容器例如panel 或者table,
panel .Controls.Add(textbox);
或者
table.Controls.Add(textbox);Top
2 楼hxhbluestar(贺星河)回复于 2004-09-02 09:05:11 得分 0
将textBox控件放在Panel控件中,就可以定位了
this.panel1.Controls.Add(this.textBox1);
this.textBox1.Loaction = new Point(x,y);
Top
3 楼goody9807(http://goody9807.cnblogs.com)回复于 2004-09-02 09:19:10 得分 0
.动态添加表格行
Function AddRow(ByVal i, ByVal tr1)
Dim td1 As New TableCell()
Dim td2 As New TableCell()
Table2.CellPadding = 0
Table2.CellSpacing = 0
tr1.BackColor = Color.LightGray
td1.HorizontalAlign = HorizontalAlign.Center
td2.HorizontalAlign = HorizontalAlign.Center
td1.VerticalAlign = VerticalAlign.Middle
td1.BorderColor = Color.Black
td2.BorderColor = Color.Black
td1.BorderWidth = Unit.Pixel(1)
td2.BorderWidth = Unit.Pixel(1)
Dim txtXx As New TextBox()
txtXx.Width = Unit.Pixel(50)
txtXx.ID = "xx" + i.ToString()
td1.Text = "option" + i.ToString()
td2.Controls.Add(txtXx)
tr1.Cells.Add(td1)
tr1.Cells.Add(td2)
Table2.Rows.Add(tr1)
End Function
Function addrow2(ByVal i)
Dim txtXx As New TextBox()
txtXx.Width = Unit.Pixel(10)
txtXx.ID = "xx" + i.ToString()
Page.Controls.Add(txtXx)
End Function
Function add3(ByVal tr As TableRow)
Dim txtXx As New TextBox()
txtXx.Width = Unit.Pixel(100)
txtXx.ID = "xx" + i.ToString()
txtXx.Text = "option" + i.ToString()
Dim td As New TableCell()
td.Controls.Add(txtXx)
tr.Cells.Add(td)
Table2.Rows.Add(tr)
End Function
Table tb=new Table();
try
{
tb.Attributes.Remove("style");
tb.Atrributes.Add("style","border-style:None;width:940px;word-break:break-all; word-wrap: break-word;");
}
catch(Exception ex)
{
throw(ex);
}Top
4 楼pgwron(情伤无痕)回复于 2004-09-02 09:42:26 得分 0
心情极度不好,没分也顶Top
5 楼happyjun2000(蓝色游侠∮是非成败转头空)回复于 2004-09-02 17:50:41 得分 0
友情 upTop




