topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 18, 2024, 7:00 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jross [ switch to compact view ]

Pages: [1]
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.

Code: Visual Basic [Select]
  1. Imports System.Windows.Forms
  2.  
  3. Public Class MyDllClass
  4.     Public Sub fillListView(lv As Object)
  5.         lv.anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
  6.         lv.CheckBoxes = True
  7.         lv.FullRowSelect = True
  8.         lv.View = System.Windows.Forms.View.Details
  9.  
  10.         ' Adding ListView Columns
  11.        lv.Columns.Add("Emp Name", 100, HorizontalAlignment.Left)
  12.         lv.Columns.Add("Emp Address", 150, HorizontalAlignment.Left)
  13.         lv.Columns.Add("Title", 60, HorizontalAlignment.Left)
  14.         lv.Columns.Add("Salary", 50, HorizontalAlignment.Left)
  15.         lv.Columns.Add("Department", 60, HorizontalAlignment.Left)
  16.  
  17.         Dim str(5) As String
  18.         Dim itm As ListViewItem
  19.         str(0) = "Rob Machy"
  20.         str(1) = "100 North Ave"
  21.         str(2) = "Business Manager"
  22.         str(3) = "89,000"
  23.         str(4) = "Development"
  24.         itm = New ListViewItem(str)
  25.         lv.Items.Add(itm)
  26.  
  27.         str(0) = "Bob Machy"
  28.         str(1) = "101 North Ave"
  29.         str(2) = "Business Manager"
  30.         str(3) = "89,001"
  31.         str(4) = "Development 1"
  32.         itm = New ListViewItem(str)
  33.         lv.Items.Add(itm)
  34.  
  35.     End Sub
  36.  
  37. End Class
   

Pages: [1]