# Re: DataGrid控制项的ButtonClick 事件

Posted by 小v on June 25, 1999 at 08:51:33:

In Reply to: Re: DataGrid控制项的ButtonClick 事件 posted by Daniel on June 24, 1999 at 12:32:03:

: 问的清楚些
: 我希望在我按下DataGrid的某个储存格时,我想要让特定
: 的控制项(如combo)停在那个储存格上供人编辑,并将编
: 辑完的结果回写入DataGrid,那我该怎样作呢?

在FORM上先放置一个ComboBox(叫做combo1), visible设为False

Sub form_load()
combo1.additem="1111"
combo1.additem="2222"
combo1.additem="3333"
dbgrid1.columns("栏位一").locked=true '
end sub

sub dbgrid1_buttonClick(ByVal ColIndex as integer)
if dbgrid1.columns(ColIndex).caption="栏位一" then
combo1.text=dbgrid1.text '将dbgrid1的值给combo1
...将combo1的位置移到适当位置.....
combo1.visible=true '让combobox可看见
combo1.setfocus '让combobox取得焦点
sendkeys "%{DOWN}" '自动将combobox下拉
endif
end sub

sub combo1_click()
combo1.visible=false '点选combobox之后将它隐藏
dbgrid1.text=combo1.text '将combobox的值给dbgrid1
end sub

Follow Ups: