Results 1 to 2 of 2

Thread: datagrids and arraylists

  1. #1

    Thread Starter
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    Cool datagrids and arraylists

    Hi there,

    I have created a datagrid that takes an arraylist as its datasource. This works fine except when I delete an item. I get an error that tells me that the index is out of range. The question is how do I tell the datagrid that I have removed a row from the arraylist?

    Thanks
    Ken

  2. #2

    Thread Starter
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    Re: datagrids and arraylists

    I figured this out on my own. Use the currenyManager
    VB Code:
    1. Dim cm As CurrencyManager
    2.         Dim removeAt As Integer
    3.  
    4.         cm = Me.dgSICs.BindingContext(Me.dgSICs.DataSource)
    5.         removeAt = cm.Position
    6.  
    7.         If cm.Count <= 1 Then
    8.             MsgBox("Sorry, you can't have an empty list")
    9.             Return
    10.         End If
    11.  
    12.         If removeAt > 0 Then
    13.             cm.Position = (removeAt - 1)
    14.         End If
    15.  
    16.         sicArrayList.RemoveAt(removeAt)
    17.  
    18.         cm.Refresh()

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