Results 1 to 4 of 4

Thread: stopping the combo index changed event

  1. #1

    Thread Starter
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530

    stopping the combo index changed event

    I have an array list that I use as the datasource of a combobox. When I set the datasource of the combo equal to the arraylist, it triggers the combo index changed event once for every item in the array list.

    Now usually this wouldn't matter but in this case as there is a sizeable amount of code that runs for the index changed event, I don't want this to happen.

    My work around is a boolean for the event to run or not but this is ugly, is there any other way around this?

  2. #2
    Lively Member sameer spitfire's Avatar
    Join Date
    Nov 2001
    Location
    India
    Posts
    120
    try this
    combo.items.addrange(arraylist)
    with Regards
    sameer Mulgaonkar

  3. #3
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.  
    3.         Dim employees() As String = New String() {"Hamilton, David", _
    4.             "Hensien, Kari", "Hammond, Maria", "Harris, Keith", _
    5.             "Henshaw, Jeff D.", "Hanson, Mark", "Harnpadoungsataya, Sariya", _
    6.             "Harrington, Mark", "Harris, Keith", "Hartwig, Doris", _
    7.             "Harui, Roger", "Hassall, Mark", "Hasselberg, Jonas", _
    8.             "Harnpadoungsataya, Sariya", "Henshaw, Jeff D.", "Henshaw, Jeff D.", _
    9.             "Hensien, Kari", "Harris, Keith", "Henshaw, Jeff D.", _
    10.             "Hensien, Kari", "Hasselberg, Jonas", "Harrington, Mark", _
    11.             "Hedlund, Magnus", "Hay, Jeff", "Heidepriem, Brandon D."}
    12.  
    13.         ComboBox1.Items.Clear()
    14.         ComboBox1.Items.AddRange(employees)
    15.         ComboBox1.SelectedIndex = 0
    16.  
    17.     End Sub
    18.  
    19.     Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    20.  
    21.         MsgBox(ComboBox1.Items.Item(ComboBox1.SelectedIndex))
    22.  
    23.     End Sub

    I got it from MS. Works perfect.
    Please rate my post.

  4. #4

    Thread Starter
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    ok well I tried this

    Me.ComboBox1.Items.AddRange(myArrayList)

    but got this error:
    arraylist cannot be converted to a one dimesional array.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width