Click here to Skip to main content
15,895,709 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Error to close form Pin
nei200925-Apr-17 14:13
nei200925-Apr-17 14:13 
GeneralRe: Error to close form Pin
Eddy Vluggen25-Apr-17 0:57
professionalEddy Vluggen25-Apr-17 0:57 
GeneralRe: Error to close form Pin
nei200925-Apr-17 14:16
nei200925-Apr-17 14:16 
QuestionConvert list (of myclass) to ienumerable Pin
JR21217-Apr-17 6:47
JR21217-Apr-17 6:47 
AnswerRe: Convert list (of myclass) to ienumerable Pin
Dave Kreskowiak17-Apr-17 6:52
mveDave Kreskowiak17-Apr-17 6:52 
QuestionRe: Convert list (of myclass) to ienumerable Pin
JR21217-Apr-17 7:54
JR21217-Apr-17 7:54 
AnswerRe: Convert list (of myclass) to ienumerable Pin
Ralf Meier17-Apr-17 8:41
mveRalf Meier17-Apr-17 8:41 
AnswerRe: Convert list (of myclass) to ienumerable Pin
Dave Kreskowiak17-Apr-17 13:07
mveDave Kreskowiak17-Apr-17 13:07 
Your classes have nothing in common, so your "single method to do it all" idea won't work. So, how is your "one method to rule them all" supposed to know how to handle each different class passed in the parameters?

Are you looking to take the data from these classes and format it somehow to be added to a ListView? If that's the case, you have to add something to these classes to give something in common. Create an Interface that both of these classes implements so each class can supply code to format itself to be used in a ListView:
VB
Public Interface IListViewFormat
    Function ListViewFormat() As String
End Interface

Now, each class has to implement the interface and supply the code for the ListViewFormat method.
VB
Public Class Aansluiting Implements IListViewFormat
    ... properties code ...

    Public Function ListViewFormat()
        return String.Format("{0} - {1}", ID, aansluiting)
    End Function

Then you can change your List to be a collection of IListViewFormat and pass that to your method that adds the items to a ListView.
VB
Dim collection = New List(Of IListViewFormat)
... add your items to the List and pass it to the method
Public Sub AddToListView(ByVal collection As IList(Of IListViewFormat))
    For Each item In collection
        ListView1.Items.Add(item.ListViewFormat)
    Next
End Sub

A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak


modified 18-Apr-17 19:28pm.

GeneralRe: Convert list (of myclass) to ienumerable Pin
JR21218-Apr-17 4:50
JR21218-Apr-17 4:50 
AnswerRe: Convert list (of myclass) to ienumerable Pin
Ralf Meier18-Apr-17 8:46
mveRalf Meier18-Apr-17 8:46 
QuestionMultiple slave communication via serial ports in Visual Basic 6.0 Pin
Member 1311249916-Apr-17 23:09
Member 1311249916-Apr-17 23:09 
AnswerRe: Multiple slave communication via serial ports in Visual Basic 6.0 Pin
Ralf Meier17-Apr-17 1:15
mveRalf Meier17-Apr-17 1:15 
AnswerRe: Multiple slave communication via serial ports in Visual Basic 6.0 Pin
Dave Kreskowiak17-Apr-17 3:19
mveDave Kreskowiak17-Apr-17 3:19 
QuestionHow to create a monitor Adjust brightness using track bar w/ on / off Pin
Member 1312882114-Apr-17 8:28
Member 1312882114-Apr-17 8:28 
GeneralRe: How to create a monitor Adjust brightness using track bar w/ on / off Pin
Ralf Meier14-Apr-17 23:32
mveRalf Meier14-Apr-17 23:32 
QuestionPicture box doubt Pin
Member 1267792613-Apr-17 4:24
Member 1267792613-Apr-17 4:24 
AnswerRe: Picture box doubt Pin
Richard MacCutchan13-Apr-17 4:43
mveRichard MacCutchan13-Apr-17 4:43 
Generalhow to create a 3d form and button Pin
Member 1311940712-Apr-17 12:33
Member 1311940712-Apr-17 12:33 
GeneralRe: how to create a 3d form and button Pin
Dave Kreskowiak12-Apr-17 16:55
mveDave Kreskowiak12-Apr-17 16:55 
GeneralHow to restrict label as an output to take 3 decimal place Pin
Member 1311940712-Apr-17 12:29
Member 1311940712-Apr-17 12:29 
GeneralRe: How to restrict label as an output to take 3 decimal place Pin
Dave Kreskowiak12-Apr-17 17:02
mveDave Kreskowiak12-Apr-17 17:02 
AnswerRe: How to restrict label as an output to take 3 decimal place Pin
Ralf Meier13-Apr-17 2:04
mveRalf Meier13-Apr-17 2:04 
QuestionConnection String Hash Pin
911911099-Apr-17 21:00
911911099-Apr-17 21:00 
AnswerRe: Connection String Hash Pin
Midi_Mick9-Apr-17 21:19
professionalMidi_Mick9-Apr-17 21:19 
GeneralRe: Connection String Hash Pin
911911099-Apr-17 21:22
911911099-Apr-17 21:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.