摘要:ComboBox
Select in ComboBox and add text in the textbox,
using handler KeyDown and TextChanged
Private Sub cmbAntibiotic2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbAntibiotic2.KeyDown
Try
' add by hoi 2008-11-10
If e.KeyCode = Keys.Enter Then
Call CopyComboBoxToTxtBox(Me.cmbAntibiotic2, Me.txtAbxToBeUsed)
End If
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
Private Sub CopyComboBoxToTxtBox(ByVal psComboBox As C1.Win.C1List.C1Combo, ByVal psTxtBox As System.Windows.Forms.TextBox)
' for KeyDown
Try
If ActiveControl Is Nothing Then Exit Sub
If psComboBox.SelectedIndex > -1 Then
Dim lsString As String = sCombineItem(psTxtBox.Text, vntFixNull(psComboBox.Columns(0).CellText(psComboBox.SelectedIndex)))
If lsString.Length < 30 Then
psTxtBox.Text = lsString
Else
MsgBox("This is allowed to key-in 30 Characters only.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
End If
psComboBox.SelectedIndex = -1
End If
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
Private Sub cmbAntibiotic2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAntibiotic2.TextChanged
Try
'sender.Text = BLANK
Call CopyComboBoxToTxtBoxForTextChanged(Me.cmbAntibiotic2, Me.txtAbxToBeUsed)
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
Private Sub cmbAntibiotic1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAntibiotic1.TextChanged
Try
'sender.Text = BLANK
Call CopyComboBoxToTxtBoxForTextChanged(Me.cmbAntibiotic1, Me.txtReceived)
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
Private Sub CopyComboBoxToTxtBoxForTextChanged(ByVal psComboBox As C1.Win.C1List.C1Combo, ByVal psTxtBox As System.Windows.Forms.TextBox)
' for textChanged
Try
If ActiveControl Is Nothing Then Exit Sub
If psComboBox.SelectedIndex > -1 Then
If psComboBox.Text.Length > 2 Then
Dim lsString As String = sCombineItem(psTxtBox.Text, vntFixNull(psComboBox.Columns(0).CellText(psComboBox.SelectedIndex)))
If lsString.Length < 30 Then
psTxtBox.Text = lsString
Else
MsgBox("This is allowed to key-in 30 Characters only.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
End If
psComboBox.Text = " "
End If
End If
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
------------------
熱愛生命 喜愛新奇 有趣的事物
過去 是無法改變
將來 卻能夠創造
希望使大家生活更便利
世界更美好
a guy who loves IT and life
Private
Private