Results 1 to 2 of 2

Thread: Code in a button and in toolbar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    478

    Code in a button and in toolbar

    I used code below in a button to get all checkbox value and then assign to a arraylist. It works fine.
    But, once copied it to a tollbar, arraylist only store first value.
    Is my code wrong?

    Dim aList As New ArrayList

    Dim CheckedRows As List(Of DataGridViewRow) = gridview1.GetChecked("Select")

    If CheckedRows.Count <> 0 Then

    Dim sList As String = ""

    For Each item In CheckedRows

    aList.Add(item.Cells("ID").Value.ToString)

    Next

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,041

    Re: Code in a button and in toolbar

    ArrayLists went away back in 2003, and you shouldn't still be using them. The replacement is the List(of T), though there are plenty of other alternatives. Interestingly, you actually make use of a List(of T) on the very next line. One of the potential issues with the ArrayList could be that in some cases it would store things oddly, almost like you describe, but that's not the case here.

    The thing to do is to put a breakpoint somewhere. Probably putting it on the If statement would be best. When execution stops on the breakpoint, take a look at what is in CheckedRows. From your description, CheckedRows will only hold a single item. If that is the case, that would be interesting. If that isn't the case, then the problem lies in code you didn't show us.
    My usual boring signature: Nothing

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