*!100分相送!* 关于自动生成控件锚定位置的问题 大侠们救命啊!
SqlConnection conn = new SqlConnection(@ "Server=.;database=Outlook;uid=sa;pwd=sa ");
SqlCommand cmdchage=new SqlCommand( "select S_Title,S_Con,S_sTime,S_eTime from SCHEDULE ",conn);
conn.Open();
SqlDataReader drchange=cmdchage.ExecuteReader();
while(drchange.Read())
{
TextBox tb = new TextBox();
tb.Width=504;
tb.Height=191;
tb.TextMode=TextBoxMode.MultiLine;
DropDownList dd=new DropDownList();
dd.Items.Add( "0% ");
dd.Items.Add( "10% ");
dd.Items.Add( "20% ");
dd.Items.Add( "30% ");
dd.Items.Add( "40% ");
dd.Items.Add( "50% ");
dd.Items.Add( "60% ");
dd.Items.Add( "70% ");
dd.Items.Add( "80% ");
dd.Items.Add( "90% ");
dd.Items.Add( "100% ");
Label mylabel1 = new Label();
Label mylabel2=new Label();
Label mylabel3=new Label();
mylabel1.Text= " <br> ";
mylabel3.Text=drchange[ "S_Title "].ToString();
mylabel2.Text= "進捗率: ";
tb.Text=drchange[ "S_Con "].ToString();
TableRow row1 = new TableRow();
TableRow row2=new TableRow();
TableCell cell1 = new TableCell();
TableCell cell2=new TableCell();
TableCell cell3=new TableCell();
cell1.Controls.Add(mylabel3);
cell2.Controls.Add(mylabel2);
cell2.Controls.Add(dd);
cell3.Controls.Add(tb);
row1.Cells.Add(cell1);
row1.Cells.Add(cell2);
row2.Cells.Add(cell3);
row2.Attributes[ "colspan "]= "2 ";
this.TabInfo.Rows.Add(row1);
this.TabInfo.Rows.Add(row2);
}
conn.Close();
以上是我的代码
我想实现第一行的ROW里的两个CELL 分别向左右对齐
做了很多尝试都不能把一行里的两个单元格分开
请明白的指点一下吧 100分相送!!!!!
------解决方案--------------------
------解决方案--------------------TextAlign
------解决方案--------------------先帮楼主顶起来!
------解决方案--------------------没看明白!
一行两列分别左对齐右对齐么?
----------------------------------------
| <---------------|---------------------> |
----------------------------------------
还是这样
----------------------------------------
| <--------------> | <--------------------> |
----------------------------------------
可以用控件套吧,套出这样的结构来
先用容器控件套出这样的结构来,再在容器控件里添加Label
------解决方案--------------------LZ没试
cell1.HorizontalAlign = HorizontalAlign.Left;
cell2.HorizontalAlign = HorizontalAlign.Right;