Home > Ask the Microsoft .Net Development Experts > Visual Basic .NET Questions & Answers > How to add a key to a listview item in VB.NET
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

How to add a key to a listview item in VB.NET

Daniel Cazzulino EXPERT RESPONSE FROM: Daniel Cazzulino

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 30 December 2004
How can I add a key to a listview item in VB.NET?


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
VB.NET
Access VB .NET Windows control on client side
Converting floating values to byte form
Read data from parallel port
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET
Converting Windows applications to VB .NET
Accessing .NET components from VBScript
How I can assign an untyped dataset to a typed dataset?
Last record in the dataset is the only one updating to the database

Visual Basic .NET
Access VB .NET Windows control on client side
Drop down list server control creates error message
Converting floating values to byte form
Datagrid issue: 'onselection' is not populating
Read data from parallel port
What is the use of these constructors?
Give me an ODBC connect, with SQL authentication
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


Unfortunately, the ListView control in .NET v1.x doesn't support indexing of its items collection by key. This has been added in .NET v2. For now, you'll have to inherit the control and extend it to support this, by exposing additional methods/properties that work with keyed items. You can for example expose a KeyedItems property where you allow the addition of items with a key. When something is added with a key, you simply store the item in the base class Items collection, but keep the index in a hashtable, for example. The property you expose would have to expose the same interface (plus the keyed members) as the Items one, so you'll probably be better off inheriting from ListView.ListViewItemCollection.
Once you have your custom control (class), it's just a matter of adding it to the toolbox manually or just doing a find-and-replace to change the instances you already have.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts