DataGrid数字显示

lesli 2003-10-20 08:43:10
开发版本1.0 C#+sql2000

在框架1.0 中 DataGrid数字显示 整数为如1 显示为1
在框架1.1中 DataGrid数字显示 整数为如1 显示为1.0000
如何把能在1.1中还是显示与1.0格式一样
...全文
65 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
houlinghouling 2003-10-22
  • 打赏
  • 举报
回复
在写SQL语句的时候就换类型好了!
weilt 2003-10-22
  • 打赏
  • 举报
回复
在写SQL语句的时候就换类型好了!
oystered 2003-10-22
  • 打赏
  • 举报
回复
转化类型吧
.Tostring
ruanyuping 2003-10-22
  • 打赏
  • 举报
回复
up
haoliqi 2003-10-20
  • 打赏
  • 举报
回复
正则表达式{d:0}
VB DataGrid分页 请看: 数据库:test2000.mdb 表:numbers 字段:Id(自动编号),anumber(数字) 因为DataGrid控件我们采用直接绑定记录集来显示数据.所以分页处理我们采用了间接的办法,定义另一个记录集objrs,将分页后的记录集付给objrs.然后绑定DataGrid ''效果还不错 , 我加了详细地注释,像pagesize, AbsolutePage的用法可参考msdn VB中新建工程,form中添加DataGrid控件,按钮cmdPrevious和cmdNext,文本框txtPage ''引用microsoft active data object 2.x object library Option Explicit Dim conn As ADODB.Connection Dim lCurrentPage As Long Private Sub cmdNext_Click() lCurrentPage = lCurrentPage + 1 Call Loadcontrol(lCurrentPage) End Sub Private Sub cmdPrevious_Click() If lCurrentPage > 1 Then lCurrentPage = lCurrentPage - 1 Call Loadcontrol(lCurrentPage) End If End Sub Private Sub Form_Load() Set conn = New ADODB.Connection conn.CursorLocation = adUseClient conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\test2000.mdb;" lCurrentPage = 1 Call Loadcontrol(lCurrentPage) End Sub Private Sub Loadcontrol(lPage As Long) Dim adoPrimaryRS As ADODB.Recordset Dim lPageCount As Long Dim nPageSize As Integer Dim lCount As Long ''每页显示的纪录 nPageSize = 10 Set adoPrimaryRS = New ADODB.Recordset adoPrimaryRS.Open "select * from numbers", conn, adOpenStatic, adLockOptimistic adoPrimaryRS.PageSize = nPageSize ''页数 lPageCount = adoPrimaryRS.PageCount If lCurrentPage > lPageCount Then lCurrentPage = lPageCount End If adoPrimaryRS.AbsolutePage = lCurrentPage ''定义另一个记录集 Dim objrs As New ADODB.Recordset ''添加字段名称 For lCount = 0 To adoPrimaryRS.Fields.Count - 1 objrs.Fields.Append adoPrimaryRS.Fields(lCount).Name, adVarChar, adoPrimaryRS.Fields(lCount).DefinedSize Next ''打开记录集 objrs.Open ''将指定记录数循环添加到objrs中 For lCount = 1 To nPageSize objrs.AddNew objrs!id = adoPrimaryRS!id objrs!anumber = adoPrimaryRS!anumber adoPrimaryRS.MoveNext Next ''绑定 Set DataGrid1.DataSource = objrs ''在文本框显示页数 txtPage = lPage & "/" & adoPrimaryRS.PageCount End Sub Private Sub Form_Unload(Cancel As Integer) If Not conn Is Nothing Then conn.Close End If Set conn = Nothing End Sub ‘文本框中输入页数,回车跳转到指定位置 Private Sub txtPage_KeyDown(KeyCode As Integer, Shift As Integer) lCurrentPage = Val(txtPage.Text) Call Loadcontrol(lCurrentPage) End Sub

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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