摘要:FillComboBox
Public Sub FillComboWard(ByRef pcboAny As C1.Win.C1List.C1Combo)
Try
Dim ltRecKeys As New gtRecordKeys
Dim lsSQLString As String = BLANK
With ltRecKeys
.TableName = "Bed BE"
.SQLExtraSelect = ", Department DE"
.NumberOfKeys = 0
Erase .LastSearchKeyValues
.SQLExtraCriteria = " BE.Bed_Available = " & BED_AVAILABLE_YES
.SQLExtraCriteria += " And BE.Dept_Code = DE.Dept_Code"
.NumberOfRequiredFields = 2
ReDim .RequiredFields(.NumberOfRequiredFields)
.RequiredFields(0) = "Distinct Dept_Code = rtrim(DE.Dept_Code)"
.RequiredFields(1) = "Dept_EngName = rtrim(DE.Dept_EngName)"
.SQLOrder = BLANK
End With
Call GenerateSqlString(ltRecKeys)
'lsSQLString = ltRecKeys.SQLString
'lsSQLString += " Union "
'lsSQLString += " SELECT Dept_Code = 'ALL' , Dept_EngName = 'ALL'"
'lsSQLString += " ORDER by Dept_Code "
'Dim cmWard As OleDbCommand = New OleDbCommand(lsSQLString, gcnOLEDBHIS)
'Dim daWard As OleDbDataAdapter = New OleDbDataAdapter(cmWard)
'Dim dsWard As DataSet = New DataSet
'daWard.Fill(dsWard, "Ward")
'Dim dvWard As DataView = New DataView(dsWard.Tables("Ward"))
'pcboAny.DataSource = dvWard
Call FillComboDataSet(pcboAny, ltRecKeys, True)
pcboAny.HScrollBar.Style = C1.Win.C1List.ScrollBarStyleEnum.None
pcboAny.Splits(0).DisplayColumns(0).Width = 50
pcboAny.Splits(0).DisplayColumns(1).Width = 300
pcboAny.ValueMember = "Dept_Code"
pcboAny.DisplayMember = "Dept_Code"
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
show the selected value
Public Sub FillComboByValue(ByRef pCombo As C1.Win.C1List.C1Combo, ByVal pValue As Object)
' 06-07-2006 by Edmond Tam
' edit by Hoi 2008-11-13
' most of the time pInValue is String
' Senario 1
' DataSet = Int, pValue = Int, It works
' Senario 2
' DataSet = String, pValue = String, It works
' Senario 3
' DataSet = Int, pValue = String, It need to handle " 5"
Try '
Dim liRow As Integer
Dim liRow2 As Integer
Dim pInValue2 As String = pValue
If vntFixNull(pValue).Equals(BLANK) Then Exit Sub
If VarType(pValue).Equals(VariantType.String) Then
' Senario 2
liRow2 = pCombo.FindStringExact(pInValue2, 0, pCombo.ValueMember)
' Senario 3
If pValue <> "ALL" Then
Dim liNoOfSpace As Integer
liNoOfSpace = pCombo.Columns(pCombo.ValueMember).CellText(1).Length - pValue.Length
If liNoOfSpace > 0 Then
pValue += Space(liNoOfSpace)
End If
End If
End If
' Senario 1
liRow = pCombo.FindStringExact(pValue, 0, pCombo.ValueMember)
If (liRow > -1) Then
pCombo.SelectedIndex = liRow
End If
If (liRow2 > -1) Then
pCombo.SelectedIndex = liRow2
End If
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
bind comboBox To DataSet Method1
Public Sub FillComboLabSpecimen(ByRef pcComboBox As C1.Win.C1List.C1Combo, ByVal pbAllSpecimen As Boolean)
Try
Dim ltRecKeys As gtRecordKeys
Dim liCount As Integer
With ltRecKeys
.TableName = "Lab_Specimen"
.SQLExtraSelect = BLANK
.NumberOfKeys = 0
Erase .LastSearchKeyValues
If pbAllSpecimen = False Then
.SQLExtraCriteria = "Default_Specimen = " & 1
End If
.NumberOfRequiredFields = 2
ReDim .RequiredFields(.NumberOfRequiredFields)
.RequiredFields(0) = "LS_Code"
.RequiredFields(1) = "LS_EngDesc"
.SQLOrder = "LS_EngDesc"
End With
Call GenerateSqlString(ltRecKeys)
Call FillComboDataSet(pcComboBox, ltRecKeys, False)
With pcComboBox
.DropdownWidth = 0
.HScrollBar.Style = C1.Win.C1List.ScrollBarStyleEnum.None
.Splits(0).DisplayColumns(0).Width = 0
.Splits(0).DisplayColumns(1).Width = pcComboBox.Width
.DataMode = C1.Win.C1List.DataModeEnum.Normal
.ValueMember = "LS_Code"
.DisplayMember = "LS_EngDesc"
.DropdownWidth = pcComboBox.Width
End With
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Subbind comboBox To DataSet Method2
Private Sub FillDataSetRemark()
Try
Dim ltRecKeys As gtRecordKeys
Dim liCount As Integer
With ltRecKeys
.TableName = "Lab_Remark"
.SQLExtraSelect = BLANK
.NumberOfKeys = 0
Erase .LastSearchKeyValues
.NumberOfRequiredFields = 1
ReDim .RequiredFields(.NumberOfRequiredFields)
.RequiredFields(0) = "LR_EngDesc"
.SQLOrder = "LR_EngDesc"
End With
' Construct Select SQL statement
Call GenerateSqlString(ltRecKeys)
Dim adapter As New OleDbDataAdapter
adapter.SelectCommand = New OleDbCommand(ltRecKeys.SQLString, gcnOLEDBHIS)
adapter.Fill(Me.mdsLabDataSet, "Lab_Remark")
adapter.SelectCommand.Dispose()
adapter.Dispose()
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
Call FillComboSingleCoulmn(Me.cmbRemarks, Me.mdsLabDataSet.Tables("Lab_Remark"))
Public Sub FillComboSingleCoulmn(ByRef pcboAny As C1.Win.C1List.C1Combo, ByVal psTable As System.Data.DataTable)
Try
pcboAny.DataSource = psTable.DefaultView
pcboAny.DisplayMember = vntFixNull(psTable.Columns(0).ToString)
pcboAny.ValueMember = vntFixNull(psTable.Columns(0).ToString)
pcboAny.HScrollBar.Style = C1.Win.C1List.ScrollBarStyleEnum.Automatic
pcboAny.Splits(0).DisplayColumns(0).Width = pcboAny.Width
pcboAny.DropdownWidth = pcboAny.Width
pcboAny.AutoDropDown = True
pcboAny.AutoCompletion = True
pcboAny.AutoSize = True
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
------------------
熱愛生命 喜愛新奇 有趣的事物
過去 是無法改變
將來 卻能夠創造
希望使大家生活更便利
世界更美好
a guy who loves IT and life
Public