0

Please help. Im having trouble displaying the checkbox's text in the listview form. It only display's the text of the 1st checkbox.


I cant seem to display the remaining checkbox.text. It only display's the 1st checkbox in my ListView form. I have another form for ListView.vb


Here is the code:

Public Class Abdominal
Private Sub selectAll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selectAll.CheckedChanged
If selectAll.Checked = True Then
crunches.Checked = True
legRaises.Checked = True
reverseCrunches.Checked = True
overheadLegRaise.Checked = True
declineBenchSitups.Checked = True
pullDownCableCrunches.Checked = True
End If
End Sub

Private Sub sumbit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sumbit.Click
Dim i As Integer
Dim newItem As New ListViewItem(i + 1) '// add text Item
newItem.SubItems.Add(crunches.Text)
newItem.SubItems.Add(legRaises.Text)
newItem.SubItems.Add(reverseCrunches.Text)
newItem.SubItems.Add(overheadLegRaise.Text)
newItem.SubItems.Add(declineBenchSitups.Text)
newItem.SubItems.Add(pullDownCableCrunches.Text)
ListView.ListView1.Items.Add(newItem)

ListView.Show()
End Sub
End Class

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
7
Replies
9
Views
6 Years
Discussion Span
Last Post by codeorder
1

See if this helps since you probably do not have columns added to your ListView.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListView1
            .Columns.Add("Column 1", 100) : .Columns.Add("Column 2", 100) : .Columns.Add("Column 3", 100) '// add Columns, "100" is column.Width.
            .View = View.Details '// display the Columns.
            .FullRowSelect = True '// highlight entire row when item clicked.
        End With
    End Sub
0

Sir I already have 2 columns in my listview. But it just display's crunches.text. It doesn't display the remaining 5 checkbox.text.

0

Add more Columns to your ListView, since Column 1 only displays a # and Column 2 will only display your first CheckBox.Text.

Edited by codeorder: n/a

0

Sir is it possible that only if the checkbox is checked that's the time when the values display in the listview?

1
If crunches.Checked Then newItem.SubItems.Add(crunches.Text)
        If legRaises.Checked Then newItem.SubItems.Add(legRaises.Text)
        '// etc...
2
Dim i As Integer = 0
        Dim newItem As New ListViewItem
        With newItem
            If crunches.Checked Then '// since first item, no need to declare as New item.
                .Text = (i + 1).ToString  '// add text Item
                newItem.SubItems.Add(crunches.Text)
                ListView.ListView1.Items.Add(newItem)
            End If
            If legRaises.Checked Then
                newItem = New ListViewItem '// declare as New item.
                .Text = (i + 1).ToString  '// add text Item
                .SubItems.Add(legRaises.Text)
                ListView.ListView1.Items.Add(newItem)
            End If
            '// etc...
        End With
Votes + Comments
nice as always
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.