How do DataGrid and ComboBox Interact?
Posted on 2003-02-25
I am using VB 6 and MS DataGrid control 6.0 with an Oracle database.
I have not worked with a datagrid before and I inherited this program from a person who is no longer with the company.
On the field I am having a problem with, the datagrid (dgParams) is working with a combobox (cmbSeismicCategory).
User simply clicks on the dgParams datagrid column that has the cmbSeismicCategory combobox when the value is null. Without the user even selecting a value in the combobox, the value changes in the database to last
value on the combobox selection list.
I have isolated where the problem is occurring but do not understand what is happening and why.
There is not a default in the Oracle database so I focused on the program.
I am following dgParams.Text and cmbSeismicCategory.Text through the program. Reference the code below. Through LINE 3, dgParams.Text and cmbSeismicCategory.Text both equal null.
After LINE 3, the program moves to LINE 11 then dgParams.Text equals null and cmbSeismicCategory.Text equals the last value on the combobox selection list which happens to be "N/A".
Of course, LINE 12 changes dgParams.Text to "N/A" and all this has occurred with the user simply clicking on the datagrid column.
LINE 1 Private Sub FillCombo(Temp As ComboBox, StrValue As String)
LINE 2 Dim i As Integer
LINE 3 Temp.ListIndex = Temp.ListCount - 1
LINE 4 For i = 0 To Temp.ListCount - 1
LINE 5 If Temp.List(i) = StrValue Then
LINE 6 Temp.ListIndex = i
LINE 7 Exit For
LINE 8 End If
LINE 9 Next i
LINE 10 End Sub
LINE 11 Private Sub cmbSeismicCategory_Click()
LINE 12 dgParams.Text = cmbSeismicCategory.Text
LINE 13 End Sub
I appreciate your suggestions.