1
Developer's Corner / VB.NET ListView data from DLL (now working)
« on: August 28, 2015, 03:25 PM »
I want to pass the name of a directory in as a string into a DLL and and pass back some of the information about the files in the directory and put it into a ListView (or something like it). I have this working as a class, but there I can pass the list view object into the class, a DLL will not allow me to pass the list view object. So what type of object do I need to pass that will load easily into a list view with sub-items?
The only thing I could find on the internet anywhere was the list view needed to be passed as an object, but there was no example, so if that is the case I will probably have more questions like does the object than need to be cast in the DLL and if so what needs to be imported, because I was getting no where.
Thank You
I got it to work.
The only thing I could find on the internet anywhere was the list view needed to be passed as an object, but there was no example, so if that is the case I will probably have more questions like does the object than need to be cast in the DLL and if so what needs to be imported, because I was getting no where.
Thank You
I got it to work.
Code: Visual Basic [Select]
- Imports System.Windows.Forms
- Public Class MyDllClass
- Public Sub fillListView(lv As Object)
- lv.anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
- lv.CheckBoxes = True
- lv.FullRowSelect = True
- lv.View = System.Windows.Forms.View.Details
- ' Adding ListView Columns
- lv.Columns.Add("Emp Name", 100, HorizontalAlignment.Left)
- lv.Columns.Add("Emp Address", 150, HorizontalAlignment.Left)
- lv.Columns.Add("Title", 60, HorizontalAlignment.Left)
- lv.Columns.Add("Salary", 50, HorizontalAlignment.Left)
- lv.Columns.Add("Department", 60, HorizontalAlignment.Left)
- Dim str(5) As String
- Dim itm As ListViewItem
- str(0) = "Rob Machy"
- str(1) = "100 North Ave"
- str(2) = "Business Manager"
- str(3) = "89,000"
- str(4) = "Development"
- itm = New ListViewItem(str)
- lv.Items.Add(itm)
- str(0) = "Bob Machy"
- str(1) = "101 North Ave"
- str(2) = "Business Manager"
- str(3) = "89,001"
- str(4) = "Development 1"
- itm = New ListViewItem(str)
- lv.Items.Add(itm)
- End Sub
- End Class