Link to home
Start Free TrialLog in
Avatar of Jason
JasonFlag for Australia

asked on

I need to create dynamic code for objectlistview vb.net

'Runners = New List(Of DataFunctions) From { _
            'New DataFunctions With {.RunnerNum = "6", .WinOdds = "2.30", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "11", .WinOdds = "3.50", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "2", .WinOdds = "8.90", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "5", .WinOdds = "10.00", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "8", .WinOdds = "13.30", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "10", .WinOdds = "15.20", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "4", .WinOdds = "18.90", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "7", .WinOdds = "22.50", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "9", .WinOdds = "60.20", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False} _
            '}

            For Each runner In Runners
                AddHandler runner.CheckChanged, AddressOf Form1.OnCheckChanged
            Next
            'ProcessMoneyGap()
            Form1.lblField.Text = Runners.Count
            Form1.ObjectListView1.SetObjects(Runners)
            TypedList = New TypedObjectListView(Of DataFunctions)(Form1.ObjectListView1)
            TypedList.GenerateAspectGetters()

Open in new window

This code works fine but I need to create a dynamic version from a string array
the Array looks like this
"1,N,QUOTA OF ALE,NOEL WRIGHT,1,0.0,8.20,8.20,8.50"
 
The bold part of the array are the info important  to add to the listview
The code runs through the number of runners
Avatar of it_saige
it_saige
Flag of United States of America image

Is this representative of a line from a file, that has multiple lines?  What does each column represent?

-saige-
Avatar of Jason

ASKER

it is the breakdown of a huge string given by a server for horse races
it starts off like this

"OK Win Approximates 00:00:00" & vbCrLf & "SG,GOSFORD,4,STEVE BLYTH ELECTRICAL STAKE M,20081104,515,GOOD,OCAST,CLOSED,19:57:39" & vbCrLf & "3,10, , , ,19:57:00,19:58:11,19:57:22,19:56:37" & vbCrLf & "1,N,INSTANT GABBIE,PETER JOHNSON,1,0.0,10.30,11.00,7.70" & vbCrLf & "2,N,AMICA NIKITA,BARBARA CHENEY,2,0.0,25.80,24.90,29.00" & vbCrLf & "3,N,LAURIE'S STAR,LAWRENCE REFAL,3,0.0,2.30,2.10,3.20" & vbCrLf & "4,Y,ROCA BENNY,ROBERT WHITELA,4,0.0,0.01,0.01,0.01" & vbCrLf & "5,N,SPICEY SPY,LESLIE FLETCHE,5,0.0,16.00,17.90,12.30" & vbCrLf & "6,Y,ASHBY JEWEL,KEVIN ELLIOTT,6,0.0,0.01,0.01,0.01" & vbCrLf & "7,N,MUNDINE,HELEN SIMMONS,7,0.0,4.40,4.30,4.10" & vbCrLf & "8,N,MINER BRUSHES,WENDY BROWN,8,0.0,14.40,15.90,13.10" & vbCrLf & "9,Y,TURTLE NECK,WAYNE VANDERBU,0,0.0,0.01,0.01,0.01" & vbCrLf & "10,N,BOO BOO LEE,KRISTY SULTANA,4,0.0,3.80,4.30,3.20" & vbCrLf & "W, , , , , ,26507,22505,10795" & vbCrLf & "P, , , , , ,5101,4407,2921" & vbCrLf & "Q, , , , , ,2524,2197,1681" & vbCrLf & "E, , , , , ,1210,1095,816" & vbCrLf & "T, , , , , ,6998,6278,4823" & vbCrLf & "F, , , , , ,0,0,0" & vbCrLf & "D, , , , , ,0,0,0" & vbCrLf & "R, , , , , ,0,0,0" & vbCrLf & "4, , , , , ,0,0,0" & vbCrLf & "." & vbCrLf & ""

I break this down to the below list
User generated image
Then I further break in down to into individual component of the string

User generated image
does this help
basically it cycles through the races to get the information and load it into the listview.
With ObjectListview I just don't know how to code to it dynamically.  Std listview is easy but not as versatile for what I need

there need to be 2 states initially adding the data in the default state all check boxes at false

and an updated state which is on timer refreshing data where odds are updated

The objectlistview need to be sort with favorite at top
Avatar of LordWabbit
LordWabbit

Not sure if I understand the question completely, but you could create a class which extends ListViewItem and add to it the extra information you require (ie. the history).  Then you can add it to your list view and override the ToString method to show what you want to show.
I assume you want to show price changes after each poll, do you need to order it as well?
Avatar of Jason

ASKER

The code I have at the moment is static but I need to make it dynamic.
Writing to ObjectListview is not as per normal with standard Listviews.

At the moment I dont quiet understand the syntax for it hence the help.

 I need to add the items then sort by odds
By looking at your initial breakdown of the string returned from the server, you have 15 rows of data.  The first 3 rows and the last 12 rows of data contain information that are not distinctly identifying race participants (horses).  Do you need to store any of the values contained within these rows?  If so then you will create a superclass (called Race for example), and a Race will contain a group of horses (or a List(Of Horse)).  Something like:
Public Class Race
	Public Property Line1() As String
	Public Property Line2() As String
	Public Property Line3() As String
	Public Property Horses() As New List(Of Horse)
	Public Property Line14() As String
	Public Property Line15() As String
	Public Property Line16() As String
	Public Property Line17() As String
	Public Property Line18() As String
	Public Property Line19() As String
	Public Property Line20() As String
	Public Property Line21() As String
	Public Property Line22() As String
	Public Property Line23() As String
	Public Property Line24() As String
	Public Property Line25() As String
End Class

Open in new window


And then a Horse subclass -
Public Class Horse
#Region "Check Changed Event Handlers"
	Private ReadOnly _checkChangedEventHandlers As New List(Of CheckChangedEventHandler)
	Public Custom Event CheckChanged As CheckChangedEventHandler
		AddHandler(ByVal value As CheckChangedEventHandler)
			_checkChangedEventHandlers.Add(value)
		End AddHandler

		RemoveHandler(ByVal value As CheckChangedEventHandler)
			_checkChangedEventHandlers.Remove(value)
		End RemoveHandler

		RaiseEvent(ByVal sender As Object, ByVal e As CheckChangedEventArgs)
			For Each handler As CheckChangedEventHandler In _checkChangedEventHandlers
				Try
					handler.Invoke(sender, e)
				Catch ex As Exception
					Debug.WriteLine(String.Format("Exception while invoking event handler: {0}", ex))
				End Try
			Next
		End RaiseEvent
	End Event

	Protected Overridable Sub OnCheckChanged(ByVal sender As Object, ByVal e As CheckChangedEventArgs)
		RaiseEvent CheckChanged(sender, e)
	End Sub
#End Region
	Private fYesNo As Boolean
	Public Property Chute() As Integer
	Public Property YesNo() As Boolean
		Get
			Return fYesNo
		End Get
		Set(value As Boolean)
			If Not value.Equals(fYesNo) Then
				fYesNo = value
				RaiseEvent CheckChanged(Me, New CheckChangedEventArgs("YesNo", fYesNo))
			End If
		End Set
	End Property
	Public Property Name() As String
	Public Property Owner() As String
	Public Property Number() As Integer
	Public Property DecimalColumn1() As Decimal
	Public Property DecimalColumn2() As Decimal
	Public Property DecimalColumn3() As Decimal
	Public Property DecimalColumn4() As Decimal
End Class

Open in new window


So putting it all together:

Form1.Designer.vb -
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
	Inherits System.Windows.Forms.Form

	'Form overrides dispose to clean up the component list.
	<System.Diagnostics.DebuggerNonUserCode()> _
	Protected Overrides Sub Dispose(ByVal disposing As Boolean)
		Try
			If disposing AndAlso components IsNot Nothing Then
				components.Dispose()
			End If
		Finally
			MyBase.Dispose(disposing)
		End Try
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> _
	Private Sub InitializeComponent()
		Me.ObjectListView1 = New BrightIdeasSoftware.ObjectListView()
		Me.colChute = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colYesNo = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colName = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colOwner = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colNumber = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colDecimal1 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colDecimal2 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colDecimal3 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colDecimal4 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		CType(Me.ObjectListView1, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		'
		'ObjectListView1
		'
		Me.ObjectListView1.AllColumns.Add(Me.colChute)
		Me.ObjectListView1.AllColumns.Add(Me.colYesNo)
		Me.ObjectListView1.AllColumns.Add(Me.colName)
		Me.ObjectListView1.AllColumns.Add(Me.colOwner)
		Me.ObjectListView1.AllColumns.Add(Me.colNumber)
		Me.ObjectListView1.AllColumns.Add(Me.colDecimal1)
		Me.ObjectListView1.AllColumns.Add(Me.colDecimal2)
		Me.ObjectListView1.AllColumns.Add(Me.colDecimal3)
		Me.ObjectListView1.AllColumns.Add(Me.colDecimal4)
		Me.ObjectListView1.AllowColumnReorder = True
		Me.ObjectListView1.AllowDrop = True
		Me.ObjectListView1.AlternateRowBackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(240, Byte), Integer), CType(CType(220, Byte), Integer))
		Me.ObjectListView1.BackColor = System.Drawing.SystemColors.Window
		Me.ObjectListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.colChute, Me.colYesNo, Me.colName, Me.colOwner, Me.colNumber, Me.colDecimal1, Me.colDecimal2, Me.colDecimal3, Me.colDecimal4})
		Me.ObjectListView1.Cursor = System.Windows.Forms.Cursors.Default
		Me.ObjectListView1.EmptyListMsg = "This list is empty."
		Me.ObjectListView1.FullRowSelect = True
		Me.ObjectListView1.Location = New System.Drawing.Point(13, 13)
		Me.ObjectListView1.Name = "ObjectListView1"
		Me.ObjectListView1.OwnerDraw = True
		Me.ObjectListView1.Size = New System.Drawing.Size(545, 237)
		Me.ObjectListView1.TabIndex = 0
		Me.ObjectListView1.UseAlternatingBackColors = True
		Me.ObjectListView1.UseCompatibleStateImageBehavior = False
		Me.ObjectListView1.View = System.Windows.Forms.View.Details
		'
		'colChute
		'
		Me.colChute.AspectName = "Chute"
		Me.colChute.Groupable = False
		Me.colChute.Text = "Chute Number"
		'
		'colYesNo
		'
		Me.colYesNo.AspectName = "YesNo"
		Me.colYesNo.CheckBoxes = True
		Me.colYesNo.Groupable = False
		Me.colYesNo.Text = "Yes/No"
		'
		'colName
		'
		Me.colName.AspectName = "Name"
		Me.colName.Text = "Name"
		'
		'colOwner
		'
		Me.colOwner.AspectName = "Owner"
		Me.colOwner.Text = "Owner"
		'
		'colNumber
		'
		Me.colNumber.AspectName = "Number"
		Me.colNumber.Text = "Number"
		'
		'colDecimal1
		'
		Me.colDecimal1.AspectName = "DecimalColumn1"
		Me.colDecimal1.Text = "Decimal 1"
		'
		'colDecimal2
		'
		Me.colDecimal2.AspectName = "DecimalColumn2"
		Me.colDecimal2.Text = "Decimal 2"
		'
		'colDecimal3
		'
		Me.colDecimal3.AspectName = "DecimalColumn3"
		Me.colDecimal3.Text = "Decimal 3"
		'
		'colDecimal4
		'
		Me.colDecimal4.AspectName = "DecimalColumn4"
		Me.colDecimal4.Text = "Decimal 4"
		'
		'Form1
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(572, 262)
		Me.Controls.Add(Me.ObjectListView1)
		Me.Name = "Form1"
		Me.Text = "Form1"
		CType(Me.ObjectListView1, System.ComponentModel.ISupportInitialize).EndInit()
		Me.ResumeLayout(False)

	End Sub
	Friend WithEvents ObjectListView1 As BrightIdeasSoftware.ObjectListView
	Friend WithEvents colChute As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colYesNo As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colName As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colOwner As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colNumber As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colDecimal1 As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colDecimal2 As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colDecimal3 As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colDecimal4 As BrightIdeasSoftware.OLVColumn

End Class

Open in new window


Form1.vb (using a quick and dirty parse)-
Imports BrightIdeasSoftware

Public Class Form1
	Private Race As Race
	Private TypedList As TypedObjectListView(Of Horse)
	Private data As String = "OK Win Approximates 00:00:00" & vbCrLf _
	 & "SG,GOSFORD,4,STEVE BLYTH ELECTRICAL STAKE M,20081104,515,GOOD,OCAST,CLOSED,19:57:39" & vbCrLf _
	 & "3,10, , , ,19:57:00,19:58:11,19:57:22,19:56:37" & vbCrLf _
	 & "1,N,INSTANT GABBIE,PETER JOHNSON,1,0.0,10.30,11.00,7.70" & vbCrLf _
	 & "2,N,AMICA NIKITA,BARBARA CHENEY,2,0.0,25.80,24.90,29.00" & vbCrLf _
	 & "3,N,LAURIE'S STAR,LAWRENCE REFAL,3,0.0,2.30,2.10,3.20" & vbCrLf _
	 & "4,Y,ROCA BENNY,ROBERT WHITELA,4,0.0,0.01,0.01,0.01" & vbCrLf _
	 & "5,N,SPICEY SPY,LESLIE FLETCHE,5,0.0,16.00,17.90,12.30" & vbCrLf _
	 & "6,Y,ASHBY JEWEL,KEVIN ELLIOTT,6,0.0,0.01,0.01,0.01" & vbCrLf _
	 & "7,N,MUNDINE,HELEN SIMMONS,7,0.0,4.40,4.30,4.10" & vbCrLf _
	 & "8,N,MINER BRUSHES,WENDY BROWN,8,0.0,14.40,15.90,13.10" & vbCrLf _
	 & "9,Y,TURTLE NECK,WAYNE VANDERBU,0,0.0,0.01,0.01,0.01" & vbCrLf _
	 & "10,N,BOO BOO LEE,KRISTY SULTANA,4,0.0,3.80,4.30,3.20" & vbCrLf _
	 & "W, , , , , ,26507,22505,10795" & vbCrLf _
	 & "P, , , , , ,5101,4407,2921" & vbCrLf _
	 & "Q, , , , , ,2524,2197,1681" & vbCrLf _
	 & "E, , , , , ,1210,1095,816" & vbCrLf _
	 & "T, , , , , ,6998,6278,4823" & vbCrLf _
	 & "F, , , , , ,0,0,0" & vbCrLf _
	 & "D, , , , , ,0,0,0" & vbCrLf _
	 & "R, , , , , ,0,0,0" & vbCrLf _
	 & "4, , , , , ,0,0,0" & vbCrLf _
	 & "." & vbCrLf _
	 & ""

	Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
		Try
			Race = New Race()
			Dim dataItems() As String = data.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
			For i As Integer = 0 To 23
				Select Case i
					Case 0
						Race.Line1 = dataItems(i)
					Case 1
						Race.Line2 = dataItems(i)
					Case 2
						Race.Line3 = dataItems(i)
					Case 3 To 12
						Dim horseSplit() As String = dataItems(i).Split(New String() {","}, StringSplitOptions.None)
						Dim horse As New Horse
						Dim tempInteger As Integer
						Dim tempDecimal As Decimal
						For j As Integer = 0 To 8
							Select Case j
								Case 0
									horse.Chute = If(Integer.TryParse(horseSplit(j), tempInteger), tempInteger, 0)
								Case 1
									horse.YesNo = horseSplit(j) = "Y"
								Case 2
									horse.Name = horseSplit(j)
								Case 3
									horse.Owner = horseSplit(j)
								Case 4
									horse.Number = If(Integer.TryParse(horseSplit(j), tempInteger), tempInteger, 0)
								Case 5
									horse.DecimalColumn1 = If(Decimal.TryParse(horseSplit(j), tempDecimal), tempDecimal, 0)
								Case 6
									horse.DecimalColumn2 = If(Decimal.TryParse(horseSplit(j), tempDecimal), tempDecimal, 0)
								Case 7
									horse.DecimalColumn3 = If(Decimal.TryParse(horseSplit(j), tempDecimal), tempDecimal, 0)
								Case 8
									horse.DecimalColumn4 = If(Decimal.TryParse(horseSplit(j), tempDecimal), tempDecimal, 0)
							End Select
						Next
						AddHandler horse.CheckChanged, AddressOf OnCheckChanged
						Race.Horses.Add(horse)
					Case 13
						Race.Line14 = dataItems(i)
					Case 14
						Race.Line15 = dataItems(i)
					Case 15
						Race.Line16 = dataItems(i)
					Case 16
						Race.Line17 = dataItems(i)
					Case 17
						Race.Line18 = dataItems(i)
					Case 18
						Race.Line19 = dataItems(i)
					Case 19
						Race.Line20 = dataItems(i)
					Case 20
						Race.Line21 = dataItems(i)
					Case 21
						Race.Line22 = dataItems(i)
					Case 22
						Race.Line23 = dataItems(i)
					Case 23
						Race.Line24 = dataItems(i)
				End Select
			Next
			ObjectListView1.SetObjects(Race.Horses)
			TypedList = New TypedObjectListView(Of Horse)(ObjectListView1)
			TypedList.GenerateAspectGetters()
		Catch ex As Exception

		End Try
	End Sub

	Private Sub OnCheckChanged(ByVal sender As Object, ByVal e As CheckChangedEventArgs)
		If TypeOf (sender) Is Horse Then
			Dim data As Horse = CType(sender, Horse)
			MessageBox.Show(String.Format("Checked value has changed for: Horse Number - {0}; Check Property - {1} is {2}", data.Number, e.PropertyName, e.PropertyValue))
		End If
	End Sub
End Class

Public Class Race
	Public Property Line1() As String
	Public Property Line2() As String
	Public Property Line3() As String
	Public Property Horses() As New List(Of Horse)
	Public Property Line14() As String
	Public Property Line15() As String
	Public Property Line16() As String
	Public Property Line17() As String
	Public Property Line18() As String
	Public Property Line19() As String
	Public Property Line20() As String
	Public Property Line21() As String
	Public Property Line22() As String
	Public Property Line23() As String
	Public Property Line24() As String
	Public Property Line25() As String
End Class

Public Class Horse
#Region "Check Changed Event Handlers"
	Private ReadOnly _checkChangedEventHandlers As New List(Of CheckChangedEventHandler)
	Public Custom Event CheckChanged As CheckChangedEventHandler
		AddHandler(ByVal value As CheckChangedEventHandler)
			_checkChangedEventHandlers.Add(value)
		End AddHandler

		RemoveHandler(ByVal value As CheckChangedEventHandler)
			_checkChangedEventHandlers.Remove(value)
		End RemoveHandler

		RaiseEvent(ByVal sender As Object, ByVal e As CheckChangedEventArgs)
			For Each handler As CheckChangedEventHandler In _checkChangedEventHandlers
				Try
					handler.Invoke(sender, e)
				Catch ex As Exception
					Debug.WriteLine(String.Format("Exception while invoking event handler: {0}", ex))
				End Try
			Next
		End RaiseEvent
	End Event

	Protected Overridable Sub OnCheckChanged(ByVal sender As Object, ByVal e As CheckChangedEventArgs)
		RaiseEvent CheckChanged(sender, e)
	End Sub
#End Region
	Private fYesNo As Boolean
	Public Property Chute() As Integer
	Public Property YesNo() As Boolean
		Get
			Return fYesNo
		End Get
		Set(value As Boolean)
			If Not value.Equals(fYesNo) Then
				fYesNo = value
				RaiseEvent CheckChanged(Me, New CheckChangedEventArgs("YesNo", fYesNo))
			End If
		End Set
	End Property
	Public Property Name() As String
	Public Property Owner() As String
	Public Property Number() As Integer
	Public Property DecimalColumn1() As Decimal
	Public Property DecimalColumn2() As Decimal
	Public Property DecimalColumn3() As Decimal
	Public Property DecimalColumn4() As Decimal
End Class

Public Delegate Sub CheckChangedEventHandler(sender As Object, e As CheckChangedEventArgs)

Public Class CheckChangedEventArgs
	Inherits EventArgs
	Private ReadOnly _propertyName As String
	Public ReadOnly Property PropertyName() As String
		Get
			Return _propertyName
		End Get
	End Property

	Private ReadOnly _propertyValue As Boolean
	Public ReadOnly Property PropertyValue() As Boolean
		Get
			Return _propertyValue
		End Get
	End Property

	Private Sub New()

	End Sub

	Public Sub New(ByVal PropertyName As String, ByVal PropertyValue As Boolean)
		_propertyName = PropertyName
		_propertyValue = PropertyValue
	End Sub
End Class

Open in new window


Produces the following output -User generated image
-saige-
Avatar of Jason

ASKER

saige

will this work if the are more or less line properties

Public Property Line25() As String

This seems to be a complex way to achieve dynamic objectlistview.

User generated image
For this listview the only the runner number and the odds
the other columns are calculated then added

this is my code for module
Public Sub RunnerListViewData(ByVal strRaceData As String)

        Dim parts As String() = strRaceData.Split(ControlChars.CrLf.ToCharArray)
        Dim newpart As String = ""
        Dim RaceInfo As String()
        Dim x As Integer
        For Each part As String In parts
            If Not part = "" Or part = "," Or part = " " Then
                If newpart = "" Then                               'need to fix
                    newpart = part
                Else
                    newpart = newpart & "-" & part
                End If
            End If
        Next
        RaceInfo = newpart.Split(New Char() {"-"c})
        If RaceInfo.Length > 3 Then
            With RaceInfo(2)
                Dim NumRaces As String() = RaceInfo(2).Split(New Char() {","c})
                x = NumRaces(1)
            End With
        End If
        For i = 3 To x
            With RaceInfo(i)
                Dim Raceparts As String() = RaceInfo(i).Split(New Char() {","c})

            End With
        Next

        Try
            'Runners = New List(Of DataFunctions) From { _
            'New DataFunctions With {.RunnerNum = "6", .WinOdds = "2.30", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "11", .WinOdds = "3.50", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "2", .WinOdds = "8.90", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "5", .WinOdds = "10.00", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "8", .WinOdds = "13.30", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "10", .WinOdds = "15.20", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "4", .WinOdds = "18.90", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "7", .WinOdds = "22.50", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False}, _
            'New DataFunctions With {.RunnerNum = "9", .WinOdds = "60.20", .MoneyGap = "0", .Check1 = False, .Check2 = False, .Check3 = False} _
            '}

            For Each runner In Runners
                AddHandler runner.CheckChanged, AddressOf Form1.OnCheckChanged
            Next
            'ProcessMoneyGap()
            Form1.lblField.Text = Runners.Count
            Form1.ObjectListView1.SetObjects(Runners)
            TypedList = New TypedObjectListView(Of DataFunctions)(Form1.ObjectListView1)
            TypedList.GenerateAspectGetters()
        Catch ex As Exception

        End Try

    End Sub

End Module

Open in new window


this part of the code is where I want to put the code to add to objectlistview

For i = 3 To x
            With RaceInfo(i)
                Dim Raceparts As String() = RaceInfo(i).Split(New Char() {","c})

            End With
Next

Open in new window


can you help with this
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason

ASKER

Hey saige
Ill have a look with what you have done an see if i understand it.
As for the check boxes they add the runner number in place position to possible combinations

Ill let you know how i go
Avatar of Jason

ASKER

saige
would you know why i am getting this error now

User generated image
What about these warnings

User generated image
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason

ASKER

awesome works great thks heaps

One last thing
How do I order by winodds with favorite at the top.

and

How do i clear items in the objectlistview
Avatar of Jason

ASKER

Hi Saige
can you help with last??

I has tried this code and it does  not clear objectlistview

the call code is

ClearObjects()

Public Overridable Sub ClearObjects()
        If ObjectListView1.InvokeRequired Then
            ObjectListView1.Invoke(New MethodInvoker(AddressOf ClearObjects))
        Else
            If ObjectListView1.Items.Count > 0 Then
                ObjectListView1.ClearObjects()
                ObjectListView1.SetObjects(Nothing)
            End If
        End If
    End Sub

Open in new window


and i need to sort by winodds

any help would be appreciated
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason

ASKER

Is there a way to automate sort for a column
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason

ASKER

Saige you're a champ thanks again
Avatar of Jason

ASKER

@Saige
With this one I have attached a timer to the procedure.  but as it goes through the process it reset all checkboxes  state to false.  Is there a way to keep the state as it runs through the cycling process.

If I stop the timer process then selections remain as normal.

Thanks
Jason