[2005] ComboBox & DataBinding
Hi guys,
I have a combobox which when the user selects the value, the two text boxes will display the value. It works nice and great, but the user wants it so that when the form loads, that the values are not displayed until the user selects there value from the combobox.
Code:
cboCaseFileProblemCode.DataSource = dataTable
cboCaseFileProblemCode.DisplayMember = "Description"
cboCaseFileProblemCode.ValueMember = "ProblemCode"
If txtCaseFileProblemCode.DataBindings.Count > 0 Then
txtCaseFileProblemCode.DataBindings.RemoveAt(0)
End If
If txtCaseFileProblemCategory.DataBindings.Count > 0 Then
txtCaseFileProblemCategory.DataBindings.RemoveAt(0)
End If
txtCaseFileProblemCode.DataBindings.Add("TEXT", dataTable, "ProblemCode")
txtCaseFileProblemCategory.DataBindings.Add("TEXT", dataTable, "CategoryName")
cboCaseFileProblemCode.SelectedIndex = -1
Here is what I am attempting to do
Code:
cboCaseFileProblemCode.SelectedIndex = -1
txtCaseFileProblemCode.Clear()
txtCaseFileProblemCategory.Clear()
What happens is the combo box is empty, and also the textboxes, but when I select the first item, the two textboxes do no put the values in. But if I select anything other than that It shows the values. Is there a way I can sort this out?
Thank you in advance..
Re: [2005] ComboBox & DataBinding
Sorry for being impatient, just need this item out of the way very soonish.
Re: [2005] ComboBox & DataBinding
After you fill your datatable, you insert a blank row to it at index 0, Then call datatable.AcceptChanges (so later you don't accidentally insert a blank row to your database if you update the the data from your datatable). Now hadle the combobox.selectedindexchanged event, and test if the selected index = 0 (that is the 1st blank row in your datatable), you disable the textboxes so that the user can't make changes to that row (thus changing the rowstate to modified).