We help IT Professionals succeed at work.

checkbox in 4,5,6 column of listview

Jason
Jason asked
on
294 Views
Last Modified: 2014-11-27
Just wonder how to put checkboxes in 4,5,6 column of a listview
Comment
Watch Question

it_saigeDeveloper
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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-

Author

Commented:
For some reason it error
can you help????

Author

Commented:
sorry see attachment
Error.png

Author

Commented:
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

Author

Commented:
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_saigeDeveloper
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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-

Author

Commented:
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

Author

Commented:
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

Author

Commented:
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
it_saigeDeveloper
CERTIFIED EXPERT
Distinguished Expert 2019

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

-saige-

Author

Commented:
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

Author

Commented:
Need 3  checkboxes for every entry

Author

Commented:
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_saigeDeveloper
CERTIFIED EXPERT
Distinguished Expert 2019

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

-saige-

Author

Commented:
No can check all 3 or 2 or 1

Author

Commented:
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
Developer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Great think i can work with that.

Thx for your help
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.