ASP.NET – 如何在C#表上设置Cells-Width-Percentage
发布时间:2020-12-16 03:35:28 所属栏目:asp.Net 来源:网络整理
导读:大家好!我有一个System.Web.UI.WebControls.Table,单元格(控件)的宽度(默认为20%).我想改变这个百分比 – 40%/ 20%/ 20%/ 10%/ 10% 我想要关注: 如何在此单元格(控件)上设置不同的宽度? 这是我的代码: Table myTbl = new Table();TableRow tRow1 =
大家好!我有一个System.Web.UI.WebControls.Table,单元格(控件)的宽度(默认为20%).我想改变这个百分比 – > 40%/ 20%/ 20%/ 10%/ 10%
我想要关注: 如何在此单元格(控件)上设置不同的宽度? 这是我的代码: Table myTbl = new Table(); TableRow tRow1 = new TableRow(); //Row1 Cells Controls TextBox txt11 = new TextBox(); txt11.ID = "txtDest11"; txt11.Height = 19; //txt11.Width = Unit.Percentage(40); TextBox txt12 = new TextBox(); txt12.ID = "txtKmInCity12"; txt12.Height = 19; TextBox txt13 = new TextBox(); txt13.ID = "txtKmOutCity13"; txt13.Height = 19; DateTimeControl dt11 = new DateTimeControl(); dt11.DateOnly = true; dt11.ShowWeekNumber = true; dt11.LocaleId = 1026; DateTimeControl dt12 = new DateTimeControl(); dt12.DateOnly = true; dt12.ShowWeekNumber = true; dt12.LocaleId = 1026; tRow1 = new TableRow(); tRow1.Visible = true; TableCell tCellZero = new TableCell(); tCellZero.Controls.Add(rowNo); tRow1.Cells.Add(tCellZero); TableCell tCellOne = new TableCell(); tCellOne.Controls.Add(txt11); tRow1.Cells.Add(tCellOne); TableCell tCellTwo = new TableCell(); tCellTwo.Controls.Add(dt11); tRow1.Cells.Add(tCellTwo); TableCell tCellThree = new TableCell(); tCellThree.Controls.Add(dt12); tRow1.Cells.Add(tCellThree); TableCell tCellFour = new TableCell(); tCellFour.Controls.Add(txt12); tRow1.Cells.Add(tCellFour); TableCell tCellFive = new TableCell(); tCellFive.Controls.Add(txt13); tRow1.Cells.Add(tCellFive); myTbl.Rows.Add(tRow1); 结果: 解决方法
添加宽度到TableCell.用这个:
TableCell myTableCell = new TableCell(); myTableCell.Width = new Unit("25%"); 要么 myTableCell.Style.Add("width","25%"); 更新: 对于文本框: TextBox txt11 = new TextBox(); txt11.ID = "txtDest11"; txt11.Height = 19; txt11.Style.Add("width","100%"); 对于TableCells: TableCell tCellOne = new TableCell(); tCellOne.Style.Add("width","40%"); tCellOne.Controls.Add(txt11); tRow1.Cells.Add(tCellOne); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 我什么时候应该使用Webservice属性System.Compo
- 从2.0到3.5的ASP.NET框架效应?
- 如何将页面从asp.net发布到经典ASP
- asp.net-identity – AspNetCore – 使用Google身份验证时更
- 重构ASP.NET 2.0应用程序更“现代”
- asp.net-mvc-4 – 为kendo ui元素添加jquery验证
- asp.net – 如何从浏览器历史记录中删除页面?
- asp.net-mvc-3 – 具有最佳实践的示例N层ASP.NET MVC3应用程
- ASP.net C#一个响应对象上的多个文档
- asp.net – 程序集与Windows Azure上的IIS使用的64位处理器
推荐文章
站长推荐
- asp.net-mvc – 在vs 2010中运行asp.net mvc 2项
- asp.net – Nlog不创建相对于网站项目的文件
- asp.net-mvc – ASP.NET MVC ViewModel自动生成
- 如何使用ASP.NET创建一个非常简单的Web代理?
- 单元测试ASP.NET WebAPI控制器的POST操作
- asp.net – 检测是否加载了HttpModule
- asp.net – Crystal Reports“加载报告失败”错误
- asp.net-mvc – ASP.NET MVC如何防止重新发布
- asp.net – 如何在x64中使用WebDev.WebServer.ex
- asp.net-mvc – 如何在asp.net C#中从http重定向
热点阅读