|
| |||||||||
| Tags: datagrid, delete image, grid, image, picture, vb datagrid |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Deleting multiple images in a grid
I have a grid in which there are two columns ("Name" and "sel"), sel is a checkboxcolumn. The user will check in my grid the users it does not want, and after he removes with this code: Code: Private Sub tsbtnDelUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbtnDelUser.Click
Dim j As Integer = dgvUsers.RowCount
For i As Integer = 0 To j
If dgvUsers.Rows(i).Cells("sel").Value = True Then
dgvUsers.Rows.RemoveAt(i)
i -= 1
End If
Next
End Sub |
|
#2
| ||||
| ||||
| Re: Deleting multiple images in a grid
Its rather a collection of the list of rows check then you do one for each in this collection. Code: Dim linesAremove As New System.Collections.Generic.List(Of DataGridViewRow)
For Each line As DataGridViewRow In mydgv.rows
If the cell of combobox is checked then
linesAremove.Add(line)
End If
Next
For Each line In linesAremove
mydgv.Rows.Remove(line)
Next |
|
#3
| |||
| |||
| Re: Deleting multiple images in a grid
How? Instead of deleting it, I added in a collection and then I made one for each of the collection of items to remove? That sounds logical, but how do you save for a row in a collection? |
|
#4
| ||||
| ||||
| Re: Deleting multiple images in a grid Quote:
Code: Dim entries as new ArrayList
for i as integer = 0 to j
If dgvUsers.Rows(i).Cells("sel").Value = True Then
entries.add(dgvUsers.Rows(i))
End If
next
for each row as DataGridRow in entries
dgvUsers.Rows.Remove(row)
next |
|
#5
| |||
| |||
| Re: Deleting multiple images in a grid
That is what I coded: Code: Dim LineRem As New System.Collections.Generic.List(Of DataGridViewRow)
For Each line As DataGridViewRow In dgvUsers.Rows
If line.Cells("sel").Value = True Then
Dim UserID As Integer = line.Cells("ID").Value
If conSE.State = ConnectionState.Open Then conSE.Close()
conSE.Open()
cmd.CommandText = "DELETE FROM UsersLogin WHERE ID =" & UserID
cmd.ExecuteNonQuery()
conSE.Close()
LineRem.Add(line)
End If
Next
For Each line In LineRem
dgvUsers.Rows.Remove(line)
Next |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Deleting multiple images in a grid" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting images in Aperture | Jensen Ackles | Windows Software | 6 | 28-05-2010 11:33 AM |
| How to display multiple images together in html | Camdean | Software Development | 5 | 23-01-2010 08:32 PM |
| Accessing multiple images at an instance | Bansi_WADIA | Windows Software | 3 | 01-12-2009 09:35 PM |
| Multiple Iso images on a dvd | Gagnesh | Operating Systems | 3 | 18-08-2009 10:23 AM |
| Downloading multiple images from a site | Zelgaro | Customize Desktop | 2 | 11-12-2008 05:53 PM |