请教VB datagrid控件复制问题?

qiluncjx qiluncjx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
写了个小程序,把数据库的记录显示到datagrid、MSHFlexGrid1等控件中,想实现对datagrid、MSHFlexGrid1中的记录全选并复制到粘贴板,科粘贴至excel等文档中,请教各位不知是否有办法实现?
...全文

相关推荐

好用的 表格控件,vb6.0

好用的表格控件。在使用中有很好的稳定性,不用注册即可使用。功能很强大,很好用,有良好的操作界面。

boss_wp

强化DataGrid控件功能代码

强化DataGrid控件功能代码,生成的类可以直接使用,实现datagrid的排序搜索以及右键菜单

jarviscao

VB OCX控件许可

多个VB OCX控件许可DataGrid,DataList

chuckchenfe

DataGrid分页

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

moyan8866

精彩编程与编程技巧-vb6中DBGRID控件在VB6中使用...

精彩编程与编程技巧-vb6中DBGRID控件在VB6中使用 ...

求伯乐
评论 1
收藏 已收藏
分享
返回顶部