大半夜的,要睡了。睡前发问

ah_2017 2011-01-19 12:48:38
请问,拖动listview和datagrid控件,改变控件大小的代码例子,谁有啊,就是找不到呢。。。找到的给我连接,我给分咯。。。。
...全文
49 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dbcontrols 2011-01-19
  • 打赏
  • 举报
回复
Dim Cnn1 As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim cnnstr As String
Dim SqlStr As String
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_NOMOVE = &H2
Const SWP_DRAWFRAME = &H20
Const GWL_STYLE = (-16)
Const WS_THICKFRAME = &H40000
Private Const SWP_FRAMECHANGED = &H20
Private Const WS_DLGFRAME = &H400000
Private Sub Command1_Click()
ResizeControl DataGrid1, Form1
End Sub

Private Sub Form_Load()
cnnstr = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\db1.mdb"
SqlStr = "Select * From 学生"
Cnn1.CursorLocation = adUseClient
Cnn1.Open cnnstr
With rst
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open SqlStr, cnnstr, , , adCmdText
End With
Set DataGrid1.DataSource = rst
DataGrid1.Caption = "共" & rst.RecordCount & "条记录"
End Sub
Function ResizeControl(ControlName As Control, FormName As Form)
Dim NewStyle As Long
NewStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
NewStyle = NewStyle Or WS_THICKFRAME
' NewStyle = NewStyle Or WS_DLGFRAME
NewStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, NewStyle)
SetWindowPos ControlName.hwnd, FormName.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_FRAMECHANGED
End Function

7,787

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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