我的做法是,因为已经有了一个按钮,所以我干脆做一个list而不是combo,思路是当我按下这个按钮时,在这个cell的左下角开始,显示这个listPrivate Sub dgRecord_ButtonClick(ByVal ColIndex As Integer)
' Assign the Column object to Co because it will be used
' more than once.
Dim Co As Column
If ColIndex = -1 Then
Exit Sub
End If
Set Co = dgRecord.Columns(ColIndex)
' Position and drop down List1 at the right edge of the
' current cell.
If Co.Caption = "colName" Then
With lstOrder
.Left = dgRecord.Left + Co.Left '+ Co.Width
.Top = dgRecord.Top + dgRecord.RowTop(dgRecord.Row) + dgRecord.RowHeight '(dgRecord.Row)
.Width = Co.Width
.Visible = True
.ZOrder 0
.SetFocus
End With
End If
End SubPrivate Sub dgRecord_Scroll(Cancel As Integer)
' Hide the list if we scroll.
lstOrder.Visible = False
End Sub
Private Sub lstOrder_Click()
' When an item is selected in lstOrder, copy its index to the
' proper column in dgRecord, then make lstOrder invisible.
dgRecord.Columns("colName").Text = lstOrder.Text 'lstOrder.ItemData(lstOrder.ListIndex + 1)
lstOrder.Visible = FalseEnd Sub
' Assign the Column object to Co because it will be used
' more than once.
Dim Co As Column
If ColIndex = -1 Then
Exit Sub
End If
Set Co = dgRecord.Columns(ColIndex)
' Position and drop down List1 at the right edge of the
' current cell.
If Co.Caption = "colName" Then
With lstOrder
.Left = dgRecord.Left + Co.Left '+ Co.Width
.Top = dgRecord.Top + dgRecord.RowTop(dgRecord.Row) + dgRecord.RowHeight '(dgRecord.Row)
.Width = Co.Width
.Visible = True
.ZOrder 0
.SetFocus
End With
End If
End SubPrivate Sub dgRecord_Scroll(Cancel As Integer)
' Hide the list if we scroll.
lstOrder.Visible = False
End Sub
Private Sub lstOrder_Click()
' When an item is selected in lstOrder, copy its index to the
' proper column in dgRecord, then make lstOrder invisible.
dgRecord.Columns("colName").Text = lstOrder.Text 'lstOrder.ItemData(lstOrder.ListIndex + 1)
lstOrder.Visible = FalseEnd Sub
解决方案 »
- 跪求怎么在9X系统下用VB获取线程的句柄
- VB编译好后,运行环境是什么?一定要安装VB吗?
- 一个小问题?在VB里面窗体右上角的红色的“X”(就是那个关闭按纽),可不可以不要,或者让它变成灰色的?
- 获取的硬盘序列号为0,怎么回事?
- 时间比较:这么写有什么 不对啊
- VB 为什么我的程序,运行时提示“端口已打开“可是我关了端口之后,有提示“只有在端口打开时,操作才有效”
- 求救:难道就没有好的加密解密方法吗??
- CreateMenu 和CreatePopupMenu的区别??
- 如何用光标建在窗口中移动焦点???
- 如果使vb的应用程序在按下ctrl+alt+del时不显示出来?(无内容)
- 数据库更新??
- 文件加密
你可以看一下。同时如果不适用的话可以模仿上位朋友。
不过如果这样的话,建议使用mshflexgrid控件。
我有个办法 你看可不可以!
DataGrid1.Columns(0).Button = True 用 DataGrid1.Columns(Index).Button 属性可以设某一列有按钮.之后再用 DataGrid1 的 ButtonClick 事件捕捉就可以了!你可以算出单元格的位置再把 Combo 现示出来就行了!
用combobox,不可调高度,还有不可调边框,很难看。
用form2.0中的combobox又会被grid复盖,不会显示,我想到用picure1包含combobox,但又有问题,问题是combobox的选择部分是因定宽度,随你怎么改变
width属性也没用,用sendmessage,又无法得到combobox的hwnd.