1 Replies - 733 Views - Last Post: 10 July 2008 - 12:49 PM Rate Topic: -----

#1 sonia.sardana  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 132
  • Joined: 01-June 08

CheckBoxes in a ListViewControl

Posted 10 July 2008 - 11:17 AM

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim i As Integer
        Dim lvitem As ListViewItem
        For i = 1 To 5
            lvitem = ListView1.Items.Add("1")
            lvitem.SubItems.Add("sonia")

        Next
    End Sub


Above code add the five items in a listview with checboxes before each item.
When we run the form,all Checkboxes are unchecked.I want that by default all checkboxes are checked...
Ur help will be highly appreciated!!!!!!

Mod Edit: Please :code:
Thanks, gabehabe :)

Is This A Good Question/Topic? 0
  • +

Replies To: CheckBoxes in a ListViewControl

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: CheckBoxes in a ListViewControl

Posted 10 July 2008 - 12:49 PM

Add the extra line
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    Dim i As Integer
        Dim lvitem As ListViewItem
        For i = 1 To 5
            lvitem = ListView1.Items.Add("1")
            lvitem.SubItems.Add("sonia")

        Me.ListView1.Items(Me.ListView1.Items.Count - 1).Checked = True

        Next
    End Sub


remember for next time to
:code:
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1