I have a form with textboxes, labels, comboboxes, etc. I have had a problem for quite some time with opening the form to display and the Comboboxes do not display the correct item. It took some time but I found that the order of two lines of code were the problem the entire time. At this point I know what is wrong, but I am unable to understand why it is wrong. SetState("View") BindControls() SetState() is a sub that sets all of the controls on the form, based on the parameters and goes something like this: Private Sub SetState(ByVal AppState As String) #Region "General Form Properties" Me.Text = "Document Record" #End Region Select Case AppState Case "Add" #Region "Button Properties" btnObsolete.Enabled = False btnEdit.Enabled = False btnCancel.Enabled = True btnSave.Enabled = True btnScan.Enabled = False btnItem.Enabled = False btnClose.Enabled = False btnHelp.Enabled = True #End Region #Region "Control Properties" pnlDocRecord.Enabled = True lblDocID.Visible = True txtName.ReadOnly = False txtDescription.ReadOnly = False lblFilePath.ForeColor = Color.Blue cboDoc.Enabled = False cboDoc.TabIndex = 2 cboDoc.TabStop = False cboDoc.ValueMember = "DocType" cboDoc.DisplayMember = "DocType" cboDoc.SelectedIndex = -1 cboOwner.Enabled = False cboOwner.TabIndex = 2 cboOwner.TabStop = False cboOwner.ValueMember = "Department" cboOwner.DisplayMember = "Department" cboOwner.SelectedIndex = -1 cboWhere.Enabled = False cboWhere.TabIndex = 2 cboWhere.TabStop = False cboWhere.ValueMember = "Where" cboWhere.DisplayMember = "Where" cboWhere.SelectedIndex = -1 rdoActive.Visible = True rdoActive.Enabled = False rdoObsolete.Visible = True rdoObsolete.Enabled = False txtName.Focus() #End Region Case "Edit", "Revise" #Region "Button Properties" btnObsolete.Enabled = False btnEdit.Enabled = False btnCancel.Enabled = True btnSave.Enabled = True btnScan.Enabled = False btnItem.Enabled = False btnClose.Enabled = False btnHelp.Enabled = True #End Region #Region "Control Properties" pnlDocRecord.Enabled = True lblDocID.Visible = True txtName.ReadOnly = False txtName.TabIndex = 0 txtName.TabStop = True txtDescription.ReadOnly = False txtDescription.TabIndex = 1 txtDescription.TabStop = True lblFilePath.ForeColor = Color.Blue cboDoc.Enabled = True cboDoc.TabIndex = 2 cboDoc.TabStop = True cboDoc.DataSource = DocBindingSource cboDoc.ValueMember = "DocType" cboDoc.DisplayMember = "DocType" cboOwner.Enabled = True cboOwner.TabIndex = 3 cboOwner.TabStop = True cboOwner.DataSource = OwnerBindingSource cboOwner.ValueMember = "Department" cboOwner.DisplayMember = "Department" cboWhere.Enabled = True cboWhere.TabIndex = 4 cboWhere.TabStop = True cboWhere.DataSource = WhereBindingSource cboWhere.ValueMember = "Where" cboWhere.DisplayMember = "Where" rdoActive.Visible = True rdoActive.Enabled = False rdoObsolete.Visible = True rdoObsolete.Enabled = False txtName.Focus() #End Region Case "View" #Region "Button Properties" btnObsolete.Enabled = False If MyUser = "DocMaster" Then btnEdit.Enabled = False Else btnEdit.Enabled = True btnCancel.Enabled = False btnSave.Enabled = False btnScan.Enabled = False btnItem.Enabled = False btnClose.Enabled = True btnHelp.Enabled = True #End Region #Region "Control Properties" pnlDocRecord.Enabled = True lblDocID.Visible = True txtName.ReadOnly = True txtName.TabIndex = 0 txtName.TabStop = False txtDescription.ReadOnly = True txtDescription.TabIndex = 1 txtDescription.TabStop = False lblFilePath.ForeColor = Color.Blue cboDoc.Enabled = False cboDoc.TabIndex = 2 cboDoc.TabStop = False cboDoc.DataSource = DocBindingSource cboDoc.ValueMember = "DocType" cboDoc.DisplayMember = "DocType" cboDoc.SelectedIndex = -1 cboOwner.Enabled = False cboOwner.TabIndex = 3 cboOwner.TabStop = False cboOwner.DataSource = OwnerBindingSource cboOwner.ValueMember = "Department" cboOwner.DisplayMember = "Department" cboOwner.SelectedIndex = -1 cboWhere.Enabled = False cboWhere.TabIndex = 4 cboWhere.TabStop = False cboWhere.DataSource = WhereBindingSource cboWhere.ValueMember = "Where" cboWhere.DisplayMember = "Where" cboWhere.SelectedIndex = -1 rdoActive.Visible = True rdoActive.Enabled = False rdoObsolete.Visible = True rdoObsolete.Enabled = False txtName.Focus() #End Region End Select End Sub BindControls() does exactly as named. It is to bind the controls with table values. Private Sub BindControls() Dim MasterBaseBindingSource As New BindingSource MasterBaseBindingSource.DataSource = MasterBase lblDocID.DataBindings.Add("Text", MasterBase.ListTable, "MasterBaseID") lblRev.DataBindings.Add("Text", MasterBase.ListTable, "Revision") txtName.DataBindings.Add("Text", MasterBase.ListTable, "Title") txtDescription.DataBindings.Add("Text", MasterBase.ListTable, "Description") lblFilePath.DataBindings.Add("Text", MasterBase.ListTable, "FilePath") cboDoc.DataBindings.Add("Text", MasterBase.ListTable, "DocType") cboWhere.DataBindings.Add("Text", MasterBase.ListTable, "WhereUsed") cboOwner.DataBindings.Add("Text", MasterBase.ListTable, "Owner") rdoActive.DataBindings.Add("Checked", MasterBase.ListTable, "Effective", True, DataSourceUpdateMode.OnValidation, CheckState.Indeterminate) rdoObsolete.DataBindings.Add("Checked", MasterBase.ListTable, "Obsolete", True, DataSourceUpdateMode.OnValidation, CheckState.Indeterminate) End Sub I am having no problem with either of the methods/subs. However, after hours and hours and hours of watching this crap run, I found that the problem is related to the order of the two lines of code (above) is reversed. I have noticed that if the order is changed, all of the table data on the form is displayed correctly, except the data for the comboboxes. Which is what blows my mind. Why is it that only the combobox data is sensitive to the order of the two lines? Whooosh!!! There it went again. Over my head!
