Hi All
i dynamically created gropbox and dynamically insert inside it listview and button
Dim count1 As Integer
Dim Listvcounter As Integer
Dim flashCounter As Integer
Private Panel As New System.Windows.Forms.GroupBox
Private ListV As New System.Windows.Forms.ListView
Private Btn As New System.Windows.Forms.Button
Private PancLeft As Integer = Me.Controls.OfType(Of GroupBox)().ToList().Count
Private cLeft As Integer = Me.Panel.Controls.OfType(Of ListView)().ToList().Count
Private BtncLeft As Integer = Me.Panel.Controls.OfType(Of Button)().ToList().Count
Public Function AddNewListV()
Panel = New GroupBox
ListV = New ListView
Btn = New Button
Dim name As Integer = 0
name += 1
Me.Controls.Add(Panel)
Panel.Location = New System.Drawing.Point((150 * PancLeft) + 5, 50)
Panel.Size = New System.Drawing.Size(145, 150)
Panel.Name = "GroBox" & PancLeft.ToString
Panel.Text = "Flash Group " & Me.PancLeft.ToString + 1
PancLeft = PancLeft + 1
Panel.Controls.Add(ListV)
ListV.Location = New System.Drawing.Point(5, 20)
ListV.Size = New System.Drawing.Size(130, 100)
ListV.Name = "ListV" & cLeft.ToString
ListV.View = View.List
cLeft = cLeft + 1
Panel.Controls.Add(Btn)
Btn.Location = New System.Drawing.Point(23, 122)
Btn.Size = New System.Drawing.Size(90, 25)
Btn.Name = BtncLeft.ToString
Btn.Text = "Ad Flashs"
AddHandler Btn.Click, AddressOf Btn_Click
BtncLeft = BtncLeft + 1
Return Panel
Return ListV
Return Btn
End Function
then add it to the form by button click
Private Sub addListViews_Click(sender As Object, e As EventArgs) Handles addListViews.Click
AddNewListV()
end sub
now when i add two listviews to the form and i want to add files to the first listview the files added into the second listview not the first
how can i fix this plz ?
here is the add files button code :
Protected Sub Btn_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ListV As ListView = TryCast(sender, ListView)
Dim Btn As Button = DirectCast(sender, Button)
If Main.OpnFlDig.ShowDialog = System.Windows.Forms.DialogResult.OK Then
Dim filepath() As String = Main.OpnFlDig.FileNames
For Each Files As String In filepath
ListV.Items.Add(System.IO.Path.GetFileName(Files))
Next
' MsgBox(ListV.Name)
End If
End Sub
best regards