kaisersoze
Centurion
- Joined
- Aug 27, 2003
- Messages
- 152
How to disable fiew items and enable fiew items based on a fireld value in Listview?
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Select Case Me.ListView1.SelectedItems(0).Text
Case "AAA"
'Do something
Case "BBB"
'Do something
End Select
End Sub
Public MustInherit Class BaseCustomNode
Inherits ListViewItem
'Implement only the contructors you need.
Public Sub New(ByVal text As String, ByVal imageindex As Integer)
Me.Text = text
Me.ImageIndex = imageindex
End Sub
Public MustOverride Sub ExecuteTask() 'May have arguments
End Class
Public Class CustomItem1
Inherits BaseCustomNode
Public Sub New(ByVal text As String, ByVal imageindex As Integer)
MyBase.New(text, imageindex)
End Sub
Public Overrides Sub ExecuteTask()
'Execute this items code
End Sub
End Class
Public Class CustomItem2
Inherits BaseCustomNode
Public Sub New(ByVal text As String, ByVal imageindex As Integer)
MyBase.New(text, imageindex)
End Sub
Public Overrides Sub ExecuteTask()
'Execute this items code
End Sub
End Class
'Assuming thet the ListView's parent form is Form1...
Dim CItem1 As New CustomItem1("MyItem1", 0)
Dim CItem2 As New CustomItem2("MyItem2", 1)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ListView1.Items.AddRange(New ListViewItem() {CItem1, CItem2})
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
CType(Me.ListView1.SelectedItems(0), BaseCustomNode).ExecuteTask()
End Sub