5,316,172 members and growing! (19,033 online)
Email Password   helpLost your password?
Languages » C / C++ Language » General     Intermediate

A simple extension to the ListView object (in report mode)

By londonman

A simple extension to the ListView object (in report mode)
VB, Windows, .NET 1.0, .NET 1.1, .NETVisual Studio, VS.NET2003, Dev

Posted: 14 Apr 2004
Updated: 22 Apr 2004
Views: 42,132
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
15 votes for this Article.
Popularity: 2.96 Rating: 2.52 out of 5
7 votes, 46.7%
1
2 votes, 13.3%
2
2 votes, 13.3%
3
2 votes, 13.3%
4
2 votes, 13.3%
5

Introduction

Hello and thanks for downloading this utility. Lvx (Listviewextra) is a simple extension to the regular ListView (in detail mode) of Windows controls. The purpose of this enhancement is to sort by any column, generate a print out, open and save, select, add, and remove items, all in one control.

I have made the actual ListView, PageSetupDialog and PrintDocument objects transparent to you (i.e.: you can still access all the usual methods). So you can implement your own code or use the extra ones:

*Selected item index is returned from the control in lvx.index.

Example (for you to implement in your code)

Private Sub Delete_Click(ByVal sender _
  As System.Object, ByVal e As System.EventArgs) Handles Delete.Click

    Lvx1.delete(lvx1.index)
End Sub
addcolumn(text As String, width As Integer, datatype As String)

Notes:

  1. Column text alignment is to the left except for decimals.
  2. There are 3 data types that you must provide when you initialize the control:
    • "s" for String
    • "d" for Decimal
    • "dt" for Date

*** This pre-assignment in building the control is necessary when sorting.

Example:

Sub columns()
    Lv.addcolumn("date", 80, "dt")
    Lv.addcolumn("payee", 80, "s")
    Lv.addcolumn("category", 80, "s")
    Lv.addcolumn("Description", 80, "s")
    Lv.addcolumn("details", 80, "s")
    Lv.addcolumn("Expense", 80, "d")
    Lv.addcolumn("Income", 80, "d")
End Sub

* fillwith (array(containing the item and its subitems))

Example:

Structure itm
    Dim dates As Date
    Dim payee As String
    Dim expense As Decimal
    Dim income As Decimal
End Structure

Sub additem()
    Dim item As itm
    item.dates="01/01/2005"
    item.payee="microsoft"
    item.expense=£1050.99
    dim t(4) as string
    t(1)=item.dates.tostring
    t(2)=item.payee.tostring
    t(3)=item.expense.tostring
    t(4)=item.income.tostring
    lvx1.fillwith(t)
End Sub

Do Not use t(0).

Note: t(0) will be assigned the item's index by lvx.

  • spreview

    short for show print preview.

  • open (filename.txt As String)

    filename must have the extension 'txt'.

  • save (filename.txt As String)

    filename must have the extension 'txt'.

  • print

    prints the contents of the ListView.

Note: to display or delete the fields of a selected item in the demo included, I've associated a context menu with the ListView.

I hope you find my work useful.. Any feedback or ideas will be much appreciated. Please email me at london_man_46@yahoo.co.uk. Thanks.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

londonman



Location: United Kingdom United Kingdom

Other popular C / C++ Language articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralThanXmemberhossien narimani3:32 23 Apr '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 22 Apr 2004
Editor: Nishant Sivakumar
Copyright 2004 by londonman
Everything else Copyright © CodeProject, 1999-2008
Web12 | Advertise on the Code Project