Advertisement

02.03.2005 at 04:59PM PST, ID: 21301294
[x]
Attachment Details

ComboBox Trouble -= clearing automatically for some unknown reason

Asked by PeterErhard in Microsoft Visual Basic.Net

Tags: box, combo, combobox

I've got a series of Combo Box's on a form which I'm populating from a SQL Server database like this:

    Private Sub LoadEmploymentStatus()

        Dim cmd As SqlCommand = cnn.CreateCommand
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "procLoadEmploymentStatus"

        Dim reader As SqlDataReader = cmd.ExecuteReader

        Dim dt As New DataTable()
        dt.Columns.Add("EmploymentStatusIDAuto", GetType(Integer))
        dt.Columns.Add("EmploymentStatus", GetType(String))

        Dim row As DataRow = dt.NewRow

        row("EmploymentStatus") = "<SELECT ITEM>"
        row("EmploymentStatusIDAuto") = "0"
        dt.Rows.Add(row)

        While reader.Read
            With reader
                row = dt.NewRow
                row("EmploymentStatus") = .GetValue(.GetOrdinal("EmploymentStatus"))
                row("EmploymentStatusIDAuto") = .GetValue(.GetOrdinal("LookUp_EmploymentStatusIDAuto"))
                dt.Rows.Add(row)
            End With
        End While

        reader.Close()

        ComboBox_EmploymentStatus.DataSource = dt
        ComboBox_EmploymentStatus.DisplayMember = "EmploymentStatus"
        ComboBox_EmploymentStatus.ValueMember = "EmploymentStatusIDAuto"

    End Sub

The problem I have is that when I validate the ComboBox to ensure the user has selected a value, e.g:

        If ComboBox_EmploymentStatus.Visible = True Then
            If CInt(ComboBox_EmploymentStatus.SelectedValue) = 0 Then
                MessageBox.Show("Please select Employment Status!", "Empty Field!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                ComboBox_EmploymentStatus.Focus()
                Exit Function
            End If
        End If

If one of the combo boxes is blank and I display the appropriate message box in the validation function it clears all the ComboBox's on the form.

Any ideas why? I don't want them to clear at all. Start Free Trial
[+][-]02.04.2005 at 10:44AM PST, ID: 13228583

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.05.2005 at 11:13AM PST, ID: 13234947

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.06.2005 at 04:02PM PST, ID: 13240659

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.06.2005 at 09:15PM PST, ID: 13241490

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.07.2005 at 12:04PM PST, ID: 13248039

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.07.2005 at 07:09PM PST, ID: 13251064

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.07.2005 at 11:46PM PST, ID: 13252044

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.08.2005 at 04:10PM PST, ID: 13260054

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.08.2005 at 04:46PM PST, ID: 13260233

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.08.2005 at 08:41PM PST, ID: 13261048

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.09.2005 at 12:39AM PST, ID: 13261925

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.09.2005 at 04:58AM PST, ID: 13263207

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.09.2005 at 12:19PM PST, ID: 13268646

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.09.2005 at 02:46PM PST, ID: 13270209

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2005 at 02:44PM PST, ID: 13299983

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2005 at 07:57PM PST, ID: 13301271

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.14.2005 at 12:22PM PST, ID: 13307840

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.15.2005 at 04:52PM PST, ID: 13320002

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.15.2005 at 07:04PM PST, ID: 13320509

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: box, combo, combobox
Sign Up Now!
Solution Provided By: fceledon
Participating Experts: 4
Solution Grade: B
 
 
[+][-]02.16.2005 at 03:13PM PST, ID: 13330042

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.16.2005 at 03:31PM PST, ID: 13330151

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32