技術(shù) 點(diǎn)
- 技術(shù)
- 點(diǎn)
- V幣
- 點(diǎn)
- 積分
- 144573
|
6#
發(fā)表于 2008-9-15 00:18:44
|
只看該作者
謝謝分享,大家所見略同,我也是使用這種方法, 不過寫成了通用函數(shù),方便設(shè)置不同列數(shù) 不同欄寬的組合框.
'===============================================================================
'-函數(shù)名稱: gt_SetComboColumnWidth
'-功能描述: 設(shè)置組合框欄位寬度,進(jìn)入時(shí)可按編碼錄入,離開時(shí)可顯示名稱
'-輸入?yún)?shù)說明: 參數(shù)1:rctr Control 控件對(duì)象
' 參數(shù)2:rstrColumnWidths String 欄位寬度
'-返回參數(shù)說明: 無
'-使用語法示例: gt_SetComboColumnWidth cboCust,"3;2;4"
'-參考:
'-使用注意: 只適用Label TextBox CommandButton ComboBox OptionButton CheckBox
'-兼容性: 97,2000,XP,2003 compatible
'-作者: 王宇虹,改進(jìn):王宇虹
'-更新日期: 2004-08-24
'===============================================================================
Public Function gt_SetComboColumnWidth(rctr As Control, rstrColumnWidths As String)
On Error Resume Next
If TypeOf rctr Is ComboBox Then
rctr.ColumnWidths = rstrColumnWidths
' rctr.RowSource = rctr.RowSource
' rctr.Requery
End If
End Function
'===============================================================================-----天鳴科技--->>>>>>>>
'-函數(shù)名稱: gt_SetCboEnterEvent
'-功能描述: 設(shè)置組合框的進(jìn)入事件
'-輸入?yún)?shù): 參數(shù)1:rctrComboBox String 組合框控件
' 可選參數(shù)2:rintType Integer 方式
' 可選參數(shù)3:rstrTemp String 其它參數(shù)
'-返回參數(shù): 無
'-使用示例: gt_SetCboEnterEvent cboCust,0
'-相關(guān)調(diào)用: 無
'-使用注意: 可設(shè)置是否自動(dòng)彈出組合框,還是沒有內(nèi)容才彈出組合框
'-兼 容 性: 97,2000,XP,2003 compatible
'-參考資料:
'-作 者: 王宇虹 修改:王宇虹
'-創(chuàng)建日期; 2002-08-26 更新日期: 2002-08-28 ,2002-11-15
'-圖 解:
'===============================================================================--<>>>>>
Public Function gt_SetCboEnterEvent(Optional rctrComboBox As Control, Optional rintType As Integer = 0, Optional rstrTemp As String)
Dim blnCancel As Boolean
Dim frm As Form
On Error Resume Next
If TypeOf rctrComboBox.Parent Is Form Then
Set frm = rctrComboBox.Parent
Else
If TypeOf rctrComboBox.Parent.Parent Is Form Then
Set frm = rctrComboBox.Parent.Parent
Else
If TypeOf rctrComboBox.Parent.Parent.Parent Is Form Then
Set frm = rctrComboBox.Parent.Parent.Parent
Else
Exit Function
End If
End If
End If
If frm Is Nothing Then Exit Function
If frm.CurrentView = 1 Then
If Nz(gt_GetParaItem("PopupWindow", rctrComboBox.Tag)) <> "" Or Nz(gt_GetParaItem("DropWindow", rctrComboBox.Tag)) <> "" Then
frm.cmdOpenSelWindow.Tag = frm.ActiveControl.name
frm.cmdOpenSelWindow.Left = frm.ActiveControl.Left + frm.ActiveControl.Width + 10
frm.cmdOpenSelWindow.Top = frm.ActiveControl.Top
If frm.AllowEdits = False Or frm.Controls(frm.cmdOpenSelWindow.Tag).Enabled = False Or frm.Controls(frm.cmdOpenSelWindow.Tag).Locked = True Then '
If frm.cmdOpenSelWindow.Object.Enabled = True Then
frm.cmdOpenSelWindow.Object.Enabled = False
End If
If frm.cmdOpenSelWindow.Visible = True Then
frm.cmdOpenSelWindow.Visible = False
End If
Else
If frm.cmdOpenSelWindow.Object.Enabled = False Then
frm.cmdOpenSelWindow.Object.Enabled = True
End If
If frm.cmdOpenSelWindow.Visible = False Then
frm.cmdOpenSelWindow.Visible = True
End If
End If
End If
End If
If Nz(rctrComboBox.ControlSource) <> "" Then
If frm.AllowEdits = False Or rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
blnCancel = True
End If
Else
If rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
blnCancel = True
End If
End If
If blnCancel Then Exit Function
If Nz(gt_GetParaItem("ComboStyle", rctrComboBox.Tag)) = "Autocbo" Then 'InStr(rctrComboBox.Tag, "autocbo") > 0
gt_SetComboColumnWidth rctrComboBox, rstrTemp
End If
Select Case rintType
Case 2
gt_ComboAutoExpand rctrComboBox, True
Case 1
gt_ComboAutoExpand rctrComboBox, False
Case 0
End Select
End Function
'===============================================================================-----天鳴科技--->>>>>>>>
'-函數(shù)名稱: gt_SetCboExitEvent
'-功能描述: 設(shè)置組合框的離開事件
'-輸入?yún)?shù): 參數(shù)1:rctrComboBox String 組合框控件
' 可選參數(shù)2:rintType Integer 方式
' 可選參數(shù)3:rstrTemp String 其它參數(shù)
'-返回參數(shù): 無
'-使用示例: gt_SetCboExitEvent cboCust,0
'-相關(guān)調(diào)用: 無
'-使用注意:
'-兼 容 性: 97,2000,XP,2003 compatible
'-參考資料:
'-作 者: 王宇虹 修改:王宇虹
'-創(chuàng)建日期; 2002-08-26 更新日期: 2002-08-28 ,2002-11-15
'-圖 解:
'===============================================================================--<>>>>>
Public Function gt_SetCboExitEvent(Optional rctrComboBox As Control, Optional rintType As Integer = 0, Optional rstrTemp As String)
Dim blnCancel As Boolean
Dim frm As Form
On Error Resume Next
If TypeOf rctrComboBox.Parent Is Form Then
Set frm = rctrComboBox.Parent
Else
If TypeOf rctrComboBox.Parent.Parent Is Form Then
Set frm = rctrComboBox.Parent.Parent
Else
If TypeOf rctrComboBox.Parent.Parent.Parent Is Form Then
Set frm = rctrComboBox.Parent.Parent.Parent
Else
Exit Function
End If
End If
End If
If frm Is Nothing Then Exit Function
If Nz(rctrComboBox.ControlSource) <> "" Then
If frm.AllowEdits = False Or rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
blnCancel = True
End If
Else
If rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
blnCancel = True
End If
End If
If blnCancel Then Exit Function
If Nz(gt_GetParaItem("ComboStyle", rctrComboBox.Tag)) = "Autocbo" Then 'InStr(rctrComboBox.Tag, "autocbo") > 0
gt_SetComboColumnWidth rctrComboBox, rstrTemp
End If
End Function |
|