Avatar of Jason
Jason
Flag for Australia asked on

checkbox in 4,5,6 column of listview

Just wonder how to put checkboxes in 4,5,6 column of a listview
Visual Basic.NET

Avatar of undefined
Last Comment
Jason

8/22/2022 - Mon
it_saige

To be honest, it might be easier to use a custom control.  Here is a good one:

http://www.codeproject.com/Articles/16009/A-Much-Easier-to-Use-ListView

-saige-
Jason

ASKER
For some reason it error
can you help????
Jason

ASKER
sorry see attachment
Error.png
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jason

ASKER
This is my code

        Dim item1 As New ListViewItem("1")
        item1.SubItems.Add("2.20")
        Dim item2 As New ListViewItem("7")
        item2.SubItems.Add("4.40")
        Dim item3 As New ListViewItem("8")
        item3.SubItems.Add("6.20")
        Dim item4 As New ListViewItem("9")
        item4.SubItems.Add("7.40")
        Dim item5 As New ListViewItem("6")
        item5.SubItems.Add("10.80")
        Dim item6 As New ListViewItem("5")
        item6.SubItems.Add("26.80")
        Dim item7 As New ListViewItem("3")
        item7.SubItems.Add("33.80")
        Dim item8 As New ListViewItem("2")
        item8.SubItems.Add("34.80")
        Dim item9 As New ListViewItem("4")
        item9.SubItems.Add("74.30")

        ObjectListView1.Items.AddRange(New ListViewItem() {item1, item2, item3, item4, item5, item6, item7, item8, item9})

Open in new window

Jason

ASKER
Worked out this part to add single item
        Dim LvItm As New RunnersData With {.RunnerNum = "1", .WinOdds = "2.20"}
        Dim LvLst As New List(Of RunnersData)
        LvLst.Add(LvItm)
        ObjectListView1.SetObjects(LvLst)

Open in new window

But I need to add multiple item

then convert data from the columns first column to intarray:
       

For Each objItem As ListViewItem In ObjectListView1.Items
MyStringArray.Add(Convert.ToInt32(objItem.SubItems(0).Text))
FieldCount += 1
Next

Open in new window

it_saige

Ok.  So where do you stand as of now?  I see that you create an instance of an Object called RunnersData.  Could you post the code for this class.

-saige-
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jason

ASKER
haven't worked out how to add multiple items to objectlistview.

then i need to collect entries in first and convet to intarray

For Each objItem As ListViewItem In ListView1.Items
MyintArray.Add(Convert.ToInt32(objItem.SubItems(0).Text))
FieldCount += 1
Next

Imports BrightIdeasSoftware

Public Class RunnersData
    Public Property RunnerNum As String
    Public Property WinOdds As String
End Class

Open in new window

Jason

ASKER
I ended up doing this
        Dim LvLst As New List(Of RunnersData)
        Dim LvItm As New RunnersData With {.RunnerNum = "1", .WinOdds = "2.20"}
        LvLst.Add(LvItm)
        Dim LvItm1 As New RunnersData With {.RunnerNum = "7", .WinOdds = "4.40"}
        LvLst.Add(LvItm1)
        ObjectListView1.SetObjects(LvLst)

Open in new window


Is there a better way
Jason

ASKER
Hey Saige

Really confused with this control
Finding it hard to even simple things like
gettlng subitemcheckbox functionality
Clearing objectlistview
Not strong on C#

Is there any other custom listview controls
Your help has saved me hundreds of hours of internet surfing.
fblack61
it_saige

I am working on an example project...  What is the purpose for each checkbox?

-saige-
Jason

ASKER
Basically this is a betting application
If you checked either 1, 2 and/or 3 the system uses the runner number to work out possible combinations
Jason

ASKER
Need 3  checkboxes for every entry
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jason

ASKER
from the checked item i need to output an intarray of the runners numbers but only one instance of the numbers.

i can then use this array to calc the number of combinations and calc the outlay.

the objectlistview needs to be sorted by the second column (Win Odds) from favorite to least favorite
it_saige

So the user can check only one of the three checkboxes?

-saige-
Jason

ASKER
No can check all 3 or 2 or 1
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Jason

ASKER
You can check all 3 check boxes
example for the fav you would check 1 2 and 3 because you estimate that they will land on of those positions
where as the second place you would check only 2 AND 3 due to estimating that they are likely to only come a 2nd or 3rd place
and one that you only this may run a third place only check the 3rd check box

Hope this helps
ASKER CERTIFIED SOLUTION
it_saige

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jason

ASKER
Great think i can work with that.

Thx for your help