Important alert: (current site time 7/15/2013 7:51:36 AM EDT)
 

VB icon

_A ListViewItem for Windows app with Value Property similar to WebForms ListItem

Email
Submitted on: 2/22/2005 4:56:29 PM
By: Duane Warsham 
Level: Beginner
User Rating: Unrated
Compatibility: VB.NET
Views: 15687
(About the author)
 
     This class code will simulate the valuable property the the Windows ListViewItem doesnt have that the Web forms ListView does include, the "Value" property. This is needed when you want to assign an integer ID with some text being displayed in a combo box. Code is included to demonstrate how to use the myListViewItem class.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: _A ListViewItem for Windows app with Value Property similar to WebForms ListItem
// Description:This class code will simulate the valuable property the the Windows ListViewItem doesnt have that the Web forms ListView does include, the "Value" property. This is needed when you want to assign an integer ID with some text being displayed in a combo box. Code is included to demonstrate how to use the myListViewItem class.
// By: Duane Warsham
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=3326&lngWId=10//for details.//**************************************

Public Class Form1
 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
' 
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim li As New myListViewItem
li.Text = "The Value Tester"
li.Value = 5
Me.Show()
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox1.DisplayMember = "Text"
ComboBox1.ValueMember = "Value"
ComboBox1.Items.Add(li)
 End Sub
'
'
 Private Sub ComboBox1_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
If Not ComboBox1.SelectedItem Is Nothing Then Label1.Text = ComboBox1.SelectedItem.value
 End Sub
End Class
'
'
'
Public Class myListViewItem
 Inherits System.Windows.Forms.ListViewItem
 Private _Value As Int64
 Public Property Value()
Get
 Return _Value
End Get
Set(ByVal Value)
 _Value = Value
End Set
 End Property
End Class


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
8/5/2005 5:03:31 AMDominic Guiritan

how to print listview
(If this comment was disrespectful, please report it.)

 
3/9/2006 9:00:16 AMAl

some built in options:

Dim de As New System.Collections.DictionaryEntry(5, "The Value Tester")
ComboBox1.DisplayMember = "Key"
ComboBox1.ValueMember = "Value"
ComboBox1.Items.Add(de)

' using .NET 2.0 Generics for Type Safety
Dim deTypeSafe As New System.Collections.Generic.KeyValuePair(Of Integer, String)(5, "The Value Tester")
ComboBox1.DisplayMember = "Key"
ComboBox1.ValueMember = "Value"
ComboBox1.Items.Add(deTypeSafe)

(If this comment was disrespectful, please report it.)

 
5/6/2006 1:10:20 PMnazmiduman

Merhaba
(If this comment was disrespectful, please report it.)

 
5/6/2006 1:17:25 PMnazmiduman

Hello this free code ours something much thanking successful good daytime,

(If this comment was disrespectful, please report it.)

 
4/21/2008 8:46:33 AMarif

Good
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.