你在一个DataTable中怎么可能指定列宽,一个表中只有数据的,没有什么列宽的概念。只能说是在显示表中数据的控件中显示列的宽度吧。比如dataGrid
解决方案 »
- 用C#写了个俄罗斯方块,图像放在panel 中,在panel中绘制图,结果图像闪烁,急求解决
- 求助C# System.IndexOutOfRangeException: 索引超出了数组界
- 刚入门,听说这里藏着很多高手!能帮我解释这句的意思吗?
- ※※ .net中如何得到每英寸多少个象素???
- 用.NET2.0做FTP文件上传,老是提示:The underlying connection was closed: The server committed a protocol violation.服务器没问题,代
- c# asp.net 数据绑定 怎么才能从数据库中获取值然后判断 计算某个值 并显示出来
- 如何让datalist默认为编辑状态
- c#在弹出的子窗口中怎么调用父窗口的函数,显示出内容即打印购票的信息
- 用正则表达式检查串中不存在某种子串,如串中不存在汉字怎么写?
- 关于用HttpWebRequest来访问需要登录页面的问题
- 显示摄像头的视频,并能提供照像功能-.net(最好源代码)(在线等,源码加送100分)
- WEBFORM 中如何实现 在同一个文件夹 有N个文件想上传,选择打开文件夹 并将其中的文件名文件读入一个ListItem
ds.Tables[0].Columns[0].MaxLength = 100;
col = new DataColumn();
col.ColumnName = "序号";
col.DataType = System.Type.GetType("System.String");
dt.Columns.Add(col);
DataGrid.DataSource = dt;
DataGrid.DataBind();
DataGrid.DataBind();用以上代码不行???
那请你写2句可以的
DataGrid.DataBind();
如何在DataGrid中写??
DataGrid.Columns[0].ItemStyle.Width
晕倒,刚刚试了一下,竟然可以这样滴~咳咳~
仔细的我也不太清楚!你查查MSDN吧!
你说的那条语句往那里加啊??我怎么出错啊
DataGrid.DataSource = dt;
DataGrid.DataBind();
以上是绑定
在帮定之后再
DataGrid.Column[0].ItemStyle.Width
具体可以参考MSDN咯。
{
if(col.ColumnName == "abc")
{
col.ItemStyle = "abc";//CSS class name
}
}
也可以这样玩~ ^o^ ~
点net嘛,随便点点就知道怎么玩了嘛~ ^_^ ~
当然,因为绑定之后才有数据啊啥的,所以这些格式化什么的东东最好在DataGrid.DataBind()之后做。