Advertisement

05.22.2008 at 12:05PM PDT, ID: 23425576
[x]
Attachment Details

Error in combobox if SelectedIndex = 0

Asked by mark_norge in Microsoft Visual Basic.Net

Tags: visual basic express 2005

Hi Experts,
I have a combobox that is filled when the index of another combobox changes. The combobox is connected to a datasource.

The values in the datasource are correct. The problem is the selectedindex. If the uses selects "add" - to trigger the sub for the combobox - the selectedindex should be 0 (this does not work) and if the user selects "modify" - to trigger the sub for the combobox - the selected index should be value on the row that the user wants to change (this works).

If the user selects "add" (selectedindex = 0) I get the following error message:

InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex

I used the value 0 before without any problem, but now it does not seem to work somehow.

Help from your side in appriciated, MBStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
Private Sub ComboBox8_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox8.SelectedIndexChanged
        'Fill size below ASN if production changes 
 
        Dim i As Integer
        Dim TableASNSizes As New DataTable
        Dim dv As New DataView(ds.Tables("Products"))
        dv.RowFilter = "Production LIKE '%" & Me.ComboBox8.Text & "%'"
        TableASNSizes = dv.ToTable("Size", True, "Size")
 
        With Me.ComboBox9
            .DataSource = TableASNSizes
            .ValueMember = "Size"
            .DisplayMember = "Size"
            If SaveCallFrom = "modify" Then
                For i = 0 To .Items.Count - 1
                    If .Items(i)("Size").ToString = ds.Tables("ASNs").Rows(SelectedRow)("Size").ToString Then
                        .SelectedIndex = i
                        Exit For
                    End If
                Next
                If i >= .Items.Count Then .SelectedIndex = -1
            Else
                .SelectedIndex = 0
            End If
        End With
 
    End Sub
[+][-]05.22.2008 at 12:34PM PDT, ID: 21626879

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.

 
[+][-]05.22.2008 at 12:46PM PDT, ID: 21626960

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.

 
[+][-]05.22.2008 at 01:06PM PDT, ID: 21627102

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.

 
[+][-]05.22.2008 at 01:22PM PDT, ID: 21627217

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.

 
[+][-]05.22.2008 at 01:28PM PDT, ID: 21627262

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.

 
[+][-]05.22.2008 at 01:48PM PDT, ID: 21627459

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.

 
[+][-]05.22.2008 at 03:25PM PDT, ID: 21628143

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: visual basic express 2005
Sign Up Now!
Solution Provided By: Sancler
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.22.2008 at 03:34PM PDT, ID: 21628194

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 / EE_QW_2_20070628