[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How: ListView with Checkboxes

Posted on 2008-06-11
5
Medium Priority
?
784 Views
Last Modified: 2008-07-03
Hello everyone,

I'm new to ListView.  I would really appreciate it if someone could show me a code sample that shows me how to have a ListView that contain columns showing the following:

1- "ID", "First Name", "Last name", "Description".
2- In a separate column titled Enabled, I would like to have checkboxes, and if possible, I would like when a checkbox is not checked, the raw shows as grayed out.
3- The ListView populated through an array of strings.
4- I would like to reorder my ListView by clicking any column header.
5- When I double click any raw I would like to get a Msgbox with all the information in the raw.

Thank a lot.
0
Comment
Question by:Wael23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Assisted Solution

by:Bruce_1975
Bruce_1975 earned 150 total points
ID: 21766924
0
 
LVL 14

Accepted Solution

by:
rachitkohli earned 900 total points
ID: 21767887
Hello, I have written the code for you. This will solve the maximum purposes you have.
To test it add ListView on the Form.
Paste the following code in the Form Load
'Designing the ListView
Call LoadToList()
'Adding items
Call AddToList("E1", "Rachit", "Kohli", "Software Engineer")
Call AddToList("E2", "Mike", "Anderson", "Director")
Call AddToList("E3", "Kevin", "Htet", "CEO")
Call AddToList("E4", "Rockey", "Arnstein", "Dealer")
Call AddToList("E5", "Sara", "Jhonson", "Marketing")
Private Sub LoadToList()
        'Code to Design the ListView
        With ListView1
            .View = View.Details
 
            .Columns.Add("ID")
            .Columns.Add("FirstName")
            .Columns.Add("LastName")
            .Columns.Add("Description")
 
            .AllowColumnReorder = True
            .FullRowSelect = True
            .GridLines = True
            .CheckBoxes = True
            .Items.Clear()
        End With
    End Sub
 
    Private Sub AddToList(ByVal strID As String, ByVal strFirstName As String, ByVal strLastName As String, ByVal strDescription As String)
        'Adding items to ListView
        Dim lsItem As ListViewItem
 
        With ListView1
            lsItem = .Items.Add(strID)
            lsItem.SubItems.Add(strFirstName)
            lsItem.SubItems.Add(strLastName)
            lsItem.SubItems.Add(strDescription)
            .BackColor = Color.LightGray
        End With
    End Sub
 
    Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
        'Msgbox on Doubleclick
        With ListView1
            If .SelectedItems.Count > 0 Then
                MsgBox(.SelectedItems(0).SubItems(1).Text & " == " & .SelectedItems(0).SubItems(2).Text)
            End If
        End With
    End Sub
 
    Private Sub ListView1_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles ListView1.ItemChecked
        'Managing the color on item checked
        If e.Item.Checked Then
            e.Item.BackColor = Color.White
        Else
            e.Item.BackColor = Color.LightGray
        End If
    End Sub

Open in new window

0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 450 total points
ID: 21774059
0
 

Author Comment

by:Wael23
ID: 21839847
Thanks for all the replies, but none of these solutions solved the problem of the second requirement "checkbox in a Listview" and the fourth requirement "reorder by clicking any column header".

Am I missing something here??

0
 
LVL 27

Expert Comment

by:planocz
ID: 21845815
Am I missing something here??
yes. Not all of the EE guy's can provide a perfect solution. Because of time, etc.
Most answers are given to help you reach your goal and to help you to go to the next level in your programming abilities..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

656 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