Solved

I need to create dynamic code for objectlistview vb.net

Posted on 2014-12-13
18
431 Views
Last Modified: 2015-01-28
'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
0
Comment
Question by:Jason
  • 10
  • 6
  • 2
18 Comments
 
LVL 32

Expert Comment

by:it_saige
ID: 40497921
Is this representative of a line from a file, that has multiple lines?  What does each column represent?

-saige-
0
 

Author Comment

by:Jason
ID: 40498287
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
list.png
Then I further break in down to into individual component of the string

list2.png
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
0
 
LVL 11

Expert Comment

by:LordWabbit
ID: 40498788
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.
0
 
LVL 11

Expert Comment

by:LordWabbit
ID: 40498795
I assume you want to show price changes after each poll, do you need to order it as well?
0
 

Author Comment

by:Jason
ID: 40498801
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
0
 
LVL 32

Expert Comment

by:it_saige
ID: 40499081
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 -Capture.JPG
-saige-
0
 

Author Comment

by:Jason
ID: 40499870
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.

columns.png
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
0
 
LVL 32

Accepted Solution

by:
it_saige earned 500 total points
ID: 40501075
The Line## properties are not intended to show a real implementation.  As I know nothing of your dataset with regards to what each piece of information means, I had to make up properties that would hold what looks like distinct data when it gets broken down.

The real purpose of the example was to show how you could parse data into a list that is readable by the ObjectListView.

Using your RunnerListViewData method I could do the same thing.  But you have to understand that I need to know about your dataset in order to provide an accurate parse method.  This is why I asked about the *columns* in my initial post.

Here is some updated code to give you an idea of what I am referring to:

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.colNumber = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colWinOdds = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colPoolPercentage = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colRunningPercentage = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colMM = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colUDiff = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colMG = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colRM = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colCheck1 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colCheck2 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		Me.colCheck3 = CType(New BrightIdeasSoftware.OLVColumn(), BrightIdeasSoftware.OLVColumn)
		CType(Me.ObjectListView1, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		'
		'ObjectListView1
		'
		Me.ObjectListView1.AllColumns.Add(Me.colNumber)
		Me.ObjectListView1.AllColumns.Add(Me.colWinOdds)
		Me.ObjectListView1.AllColumns.Add(Me.colPoolPercentage)
		Me.ObjectListView1.AllColumns.Add(Me.colRunningPercentage)
		Me.ObjectListView1.AllColumns.Add(Me.colMM)
		Me.ObjectListView1.AllColumns.Add(Me.colUDiff)
		Me.ObjectListView1.AllColumns.Add(Me.colMG)
		Me.ObjectListView1.AllColumns.Add(Me.colRM)
		Me.ObjectListView1.AllColumns.Add(Me.colCheck1)
		Me.ObjectListView1.AllColumns.Add(Me.colCheck2)
		Me.ObjectListView1.AllColumns.Add(Me.colCheck3)
		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.colNumber, Me.colWinOdds, Me.colPoolPercentage, Me.colRunningPercentage, Me.colMM, Me.colUDiff, Me.colMG, Me.colRM, Me.colCheck1, Me.colCheck2, Me.colCheck3})
		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(655, 237)
		Me.ObjectListView1.TabIndex = 0
		Me.ObjectListView1.UseAlternatingBackColors = True
		Me.ObjectListView1.UseCompatibleStateImageBehavior = False
		Me.ObjectListView1.View = System.Windows.Forms.View.Details
		'
		'colNumber
		'
		Me.colNumber.AspectName = "Number"
		Me.colNumber.Groupable = False
		Me.colNumber.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colNumber.Text = "Race #"
		Me.colNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colNumber.Width = 70
		'
		'colWinOdds
		'
		Me.colWinOdds.AspectName = "WinOdds"
		Me.colWinOdds.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colWinOdds.Text = "Win Odds"
		Me.colWinOdds.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
		Me.colWinOdds.Width = 70
		'
		'colPoolPercentage
		'
		Me.colPoolPercentage.AspectName = "PoolPercentage"
		Me.colPoolPercentage.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colPoolPercentage.Text = "Pool %"
		Me.colPoolPercentage.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
		Me.colPoolPercentage.Width = 70
		'
		'colRunningPercentage
		'
		Me.colRunningPercentage.AspectName = "RunningPercentage"
		Me.colRunningPercentage.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Right
		Me.colRunningPercentage.Text = "Running %"
		Me.colRunningPercentage.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
		Me.colRunningPercentage.Width = 70
		'
		'colMM
		'
		Me.colMM.AspectName = "MM"
		Me.colMM.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colMM.Text = "MM"
		Me.colMM.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colMM.Width = 70
		'
		'colUDiff
		'
		Me.colUDiff.AspectName = "UDiff"
		Me.colUDiff.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colUDiff.Text = "UDiff"
		Me.colUDiff.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colUDiff.Width = 70
		'
		'colMG
		'
		Me.colMG.AspectName = "MG"
		Me.colMG.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colMG.Text = "MG"
		Me.colMG.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colMG.Width = 70
		'
		'colRM
		'
		Me.colRM.AspectName = "RM"
		Me.colRM.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colRM.Text = "RM"
		Me.colRM.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colRM.Width = 70
		'
		'colCheck1
		'
		Me.colCheck1.AspectName = "Check1"
		Me.colCheck1.CheckBoxes = True
		Me.colCheck1.Groupable = False
		Me.colCheck1.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colCheck1.Text = "1"
		Me.colCheck1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colCheck1.Width = 30
		'
		'colCheck2
		'
		Me.colCheck2.AspectName = "Check2"
		Me.colCheck2.CheckBoxes = True
		Me.colCheck2.Groupable = False
		Me.colCheck2.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colCheck2.Text = "2"
		Me.colCheck2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colCheck2.Width = 30
		'
		'colCheck3
		'
		Me.colCheck3.AspectName = "Check3"
		Me.colCheck3.CheckBoxes = True
		Me.colCheck3.Groupable = False
		Me.colCheck3.HeaderTextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colCheck3.Text = "3"
		Me.colCheck3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
		Me.colCheck3.Width = 30
		'
		'Form1
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(681, 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 colNumber As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colRunningPercentage As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colMM As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colUDiff As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colMG As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colRM As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colCheck1 As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colCheck2 As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colCheck3 As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colPoolPercentage As BrightIdeasSoftware.OLVColumn
	Friend WithEvents colWinOdds As BrightIdeasSoftware.OLVColumn

End Class

Open in new window


Form1.vb -
Imports BrightIdeasSoftware

Public Class Form1
	Private Races As List(Of RaceInfo)
	Private TypedList As TypedObjectListView(Of RaceInfo)
	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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Try
			Races = New List(Of RaceInfo)
			RunnerListViewData(data)
			ObjectListView1.SetObjects(Races)
			TypedList = New TypedObjectListView(Of RaceInfo)(ObjectListView1)
			TypedList.GenerateAspectGetters()
		Catch ex As Exception

		End Try
	End Sub

	Public Sub RunnerListViewData(ByVal data As String)
		Try
			Dim raceInfo As String() = data.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
			Dim numRaces As Integer
			If raceInfo.Length > 3 Then
				With raceInfo(2)
					If Integer.TryParse(raceInfo(2).Split(New Char() {","c})(1), numRaces) Then
						For i = 3 To numRaces + 2
							With raceInfo(i)
								Dim parts As String() = raceInfo(i).Split(New Char() {","c})
								Dim info As New RaceInfo()
								If parts(0) Is Nothing OrElse Not Integer.TryParse(parts(0), info.Number) Then
									info = Nothing
								Else
									If parts(6) Is Nothing OrElse Not Decimal.TryParse(parts(6), info.WinOdds) Then
										info = Nothing
									End If
								End If
								If Not info Is Nothing Then
									AddHandler info.CheckChanged, AddressOf OnCheckChanged
									Races.Add(info)
								End If
							End With
						Next
					End If
				End With
			End If
		Catch ex As Exception

		End Try
	End Sub

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

Public Class RaceInfo
#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

#Region "Private Fields"
	Private fCheck1 As Boolean
	Private fCheck2 As Boolean
	Private fCheck3 As Boolean
#End Region

#Region "Public Properties"
	Public Property Number() As Integer
	Public Property WinOdds() As Decimal
	Public Property PoolPercentage() As Decimal
	Public Property RunningPercentage() As Decimal
	Public Property MM() As String
	Public Property UDiff() As String
	Public Property MG() As String
	Public Property RM() As String
	Public Property Check1() As Boolean
		Get
			Return fCheck1
		End Get
		Set(ByVal value As Boolean)
			If Not value.Equals(fCheck1) Then
				fCheck1 = value
				RaiseEvent CheckChanged(Me, New CheckChangedEventArgs("Check1", Check1))
			End If
		End Set
	End Property
	Public Property Check2() As Boolean
		Get
			Return fCheck2
		End Get
		Set(ByVal value As Boolean)
			If Not value.Equals(fCheck2) Then
				fCheck2 = value
				RaiseEvent CheckChanged(Me, New CheckChangedEventArgs("Check2", Check2))
			End If
		End Set
	End Property
	Public Property Check3() As Boolean
		Get
			Return fCheck3
		End Get
		Set(ByVal value As Boolean)
			If Not value.Equals(fCheck3) Then
				fCheck3 = value
				RaiseEvent CheckChanged(Me, New CheckChangedEventArgs("Check3", Check3))
			End If
		End Set
	End Property
#End Region
End Class

Public Delegate Sub CheckChangedEventHandler(ByVal sender As Object, ByVal 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 -Capture.JPG
I am just guessing the 1, 2 and 3 are the checkboxes that you have asked about in previous questions.  Again they are bound to an event so that you can perform your calculations and change the appropriate fields in the RaceInformation screen.  Example (change the OnCheckChanged event method) -
Private Sub OnCheckChanged(ByVal sender As Object, ByVal e As CheckChangedEventArgs)
	If TypeOf (sender) Is RaceInfo Then
		Dim data As RaceInfo = CType(sender, RaceInfo)
		Select Case e.PropertyName
			Case "Check1"
				If e.PropertyValue Then
					data.MM = "MM Calculation"
					data.PoolPercentage = 34.28
				Else
					data.MM = String.Empty
					data.PoolPercentage = 0.0
				End If
			Case "Check2"
				If e.PropertyValue Then
					data.MG = "MG Calculation"
					data.RunningPercentage = 52.16
				Else
					data.MG = String.Empty
					data.PoolPercentage = 0.0
				End If
			Case "Check3"
				If e.PropertyValue Then
					data.RM = "RM Calculation"
					data.UDiff = data.PoolPercentage - data.RunningPercentage
				Else
					data.RM = String.Empty
					data.UDiff = String.Empty
				End If
		End Select
	End If
End Sub

Open in new window


Produces the following -Capture.JPG
But even though you can perform the calculations in the checkchanged handler, the better solution would be to perform your calculations in the class.

-saige-
0
 

Author Comment

by:Jason
ID: 40502047
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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Jason
ID: 40502428
saige
would you know why i am getting this error now

objectlistview-error.png
What about these warnings

objectlistview-warnings.png
0
 
LVL 32

Assisted Solution

by:it_saige
it_saige earned 500 total points
ID: 40502659
The error means that you have another process using the ObjectListView.dll, so it cannot overwrite the dll when building the project.  If you have included the ObjectListView source project, you can actually just remove the source project, build it once and then place the dll into your project folder and add a reference to it, just set its Copy to Output Directory property to Copy if newer.Capture.JPG
As for the warnings, these have to do with a conflict where the compiler has found two references to the same type defined.  This, also, will be resolved if you remove the ObjectListView source project from your solution.

-saige-
0
 

Author Comment

by:Jason
ID: 40504490
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
0
 

Author Comment

by:Jason
ID: 40506815
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
0
 
LVL 32

Assisted Solution

by:it_saige
it_saige earned 500 total points
ID: 40507260
In the example I posted, using ObjectListView1.ClearObjects() or ObjectListView1.RemoveObjects(Races) clears the list.

Also you can click on the column header to sort the winodds.

-saige-
0
 

Author Comment

by:Jason
ID: 40507813
Is there a way to automate sort for a column
0
 
LVL 32

Assisted Solution

by:it_saige
it_saige earned 500 total points
ID: 40507838
You would use something like: objectListView.Sort(targetColumn, SortOrder)

In the example code this would translate to: ObjectListView1.Sort(colWinOdds, SortOrder.Descending)

-saige-
0
 

Author Closing Comment

by:Jason
ID: 40508100
Saige you're a champ thanks again
0
 

Author Comment

by:Jason
ID: 40574941
@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
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now