有关DataGrid的几个问题!

在途中 2004-07-27 12:43:08
1、从数据库读出时间填入DataGrid,我得到的效果是“2004-2-2”这种格式,有没有办法让他变成“2004年2月”这种格式?

2、想改变DataGrid中的某一列宽度,该如何做?
...全文
125 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
冰峰zoubf 2004-07-27
  • 打赏
  • 举报
回复
不是,是MappingName名
在途中 2004-07-27
  • 打赏
  • 举报
回复
up
在途中 2004-07-27
  • 打赏
  • 举报
回复
1、能否说详细点,比如举个例,因第一句有点看不懂!
2、DataGrid1.TableStyles("DataTable1").GridColumnStyles("Column1").Width = 50中的“datatable1”是表名吗?“column1”是列名吗?
thinkingforever 2004-07-27
  • 打赏
  • 举报
回复
1. select (cast(year(getdate()) as varchar(4))+'年-'+cast(Month(getdate())as varchar(2))+'月')as [Month]
冰峰zoubf 2004-07-27
  • 打赏
  • 举报
回复
1.select to_char(to_date(日期),'YYYYMMDD') as 日期1
strDate = Left(日期1, 4) & "年" & Mid(日期1, 5, 2) & "月"
2.
Dim ts As New DataGridTableStyle()
ts.MappingName = "DataTable1"
Dim cs As DataGridTextBoxColumn
cs = New DataGridTextBoxColumn()
cs.MappingName = "Column1"
cs.HeaderText = "Column1"
cs.Width = 100
ts.GridColumnStyles.Add(cs)
DataGrid1.TableStyles.Add(ts)
如果你是用像上面的格式来生成列的话,那就可以用下面的

列幅
DataGrid1.TableStyles("DataTable1").GridColumnStyles("Column1").Width = 50

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧