M
Mark L. Breen
Hello All,
I have been playing with a combo box for the last day or so, attempting to
get my head around the best or the recommended way to update them.
I had problems setting the .Text and also the .SelectedValue and also the
..SelectedText. Following comments and suggestions on the newsgroups I
settled on using the .SelectedIndex.
Below is a snippit of my code. What I do not like about it is the loop
through the entire contents of the combo box. This seems ridiculously
labour intensive. Is there are more direct way to find the index of a value
in the combo list of items?
Thanks All
Mark in Ireland
Private Function F_intGetIndexForCombo(ByVal cbo As ComboBox, ByVal
intUniqueId As Integer) As Integer
Dim intIndex As Integer
For intCount As Integer = 0 To cbo.Items.Count
cbo.SelectedIndex = intCount
If cbo.SelectedValue = mobjRecord.PIDTypeId Then
intIndex = intCount
Exit For
End If
Next
F_intGetIndexForCombo = intIndex
End Function
Private Sub S_PopulateControls()
Me.txtSessionId.Text = mobjRecord.SessionId
Me.cboPIDType.SelectedIndex = F_intGetIndexForCombo(Me.cboPIDType,
mobjRecord.PIDTypeId)
Me.cboLocalisedText.SelectedIndex =
F_intGetIndexForCombo(Me.cboLocalisedText, mobjRecord.LocalisedTestId)
Me.txtPartNum.Text = mobjRecord.PartNum
Me.txtDescription.Text = mobjRecord.Description
Me.txtCreated.Text = mobjRecord.Created
Me.txtComments.Text = mobjRecord.Comment
Me.chkActiveYN.CheckState =
CommonRoutines.F_CnvBooleanToCheckState(mobjRecord.Active)
End Sub
I have been playing with a combo box for the last day or so, attempting to
get my head around the best or the recommended way to update them.
I had problems setting the .Text and also the .SelectedValue and also the
..SelectedText. Following comments and suggestions on the newsgroups I
settled on using the .SelectedIndex.
Below is a snippit of my code. What I do not like about it is the loop
through the entire contents of the combo box. This seems ridiculously
labour intensive. Is there are more direct way to find the index of a value
in the combo list of items?
Thanks All
Mark in Ireland
Private Function F_intGetIndexForCombo(ByVal cbo As ComboBox, ByVal
intUniqueId As Integer) As Integer
Dim intIndex As Integer
For intCount As Integer = 0 To cbo.Items.Count
cbo.SelectedIndex = intCount
If cbo.SelectedValue = mobjRecord.PIDTypeId Then
intIndex = intCount
Exit For
End If
Next
F_intGetIndexForCombo = intIndex
End Function
Private Sub S_PopulateControls()
Me.txtSessionId.Text = mobjRecord.SessionId
Me.cboPIDType.SelectedIndex = F_intGetIndexForCombo(Me.cboPIDType,
mobjRecord.PIDTypeId)
Me.cboLocalisedText.SelectedIndex =
F_intGetIndexForCombo(Me.cboLocalisedText, mobjRecord.LocalisedTestId)
Me.txtPartNum.Text = mobjRecord.PartNum
Me.txtDescription.Text = mobjRecord.Description
Me.txtCreated.Text = mobjRecord.Created
Me.txtComments.Text = mobjRecord.Comment
Me.chkActiveYN.CheckState =
CommonRoutines.F_CnvBooleanToCheckState(mobjRecord.Active)
End Sub