Here is the full form code-Compile it from command window::
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1
Inherits System.Windows.Forms.Form
Public ListView1 As ListView
Public Col_Header1 As ColumnHeader
Public Col_Header2 As ColumnHeader
Public Col_Header3 As ColumnHeader
Public Col_Header4 As ColumnHeader
Public Sub New()
ListView1 = New ListView
Col_Header1 = New ColumnHeader
Col_Header2 = New ColumnHeader
Col_Header3 = New ColumnHeader
Col_Header4 = New ColumnHeader
ListView1.Columns.AddRange(New ColumnHeader() { _
Col_Header1, _
Col_Header2, _
Col_Header3, _
Col_Header4})
Col_Header1.Text = "Header1"
Col_Header1.Width = 200
Col_Header2.Text = "Header2"
Col_Header2.Width = 200
Col_Header3.Text = "Header3"
Col_Header3.Width = 200
Col_Header4.Text = "Header4"
Col_Header4.Width = 400
Dim myItems As String() = New String() { _
"Item1", _
"Item2", _
"Item3", _
"Item4"}
Dim myItems1 As String() = New String() { _
"Item11", _
"Item12", _
"Item13", _
"Item14"}
Dim myItems2 As String() = New String() { _
"Item21", _
"Item22", _
"Item23", _
"Item24"}
Dim myItems3 As String() = New String() { _
"Item31", _
"Item32", _
"Item33", _
"Item34"}
Dim myItems4 As String() = New String() { _
"Item41", _
"Item42", _
"Item43", _
"Item44"}
Dim lvi As ListViewItem = New ListViewItem(myItems)
ListView1.Items.Add(lvi)
Dim lvi1 As ListViewItem = New ListViewItem(myItems1)
ListView1.Items.Add(lvi1)
Dim lvi2 As ListViewItem = New ListViewItem(myItems2)
ListView1.Items.Add(lvi2)
Dim lvi3 As ListViewItem = New ListViewItem(myItems3)
ListView1.Items.Add(lvi3)
Dim lvi4 As ListViewItem = New ListViewItem(myItems4)
ListView1.Items.Add(lvi4)
ListView1.AllowColumnReorder = True
ListView1.Font = New System.Drawing.Font("Segoe UI",15.0!, _
System.Drawing.FontStyle.Bold, System.Drawing. _
GraphicsUnit.Point,CType(0, Byte))
ListView1.FullRowSelect = True
ListView1.HideSelection = False
ListView1.Dock = DockStyle.Fill
ListView1.Name = "listView1"
ListView1.View = View.Details
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(800,600)
Me.Controls.Add(ListView1)
Me.Text = "Deep_Research_For_ListView_Developement"
Me.Name = "Research_Form1"
Me.ResumeLayout(False)
End Sub
Public Shared Sub Main()
Dim form1 As Form1 = New Form1()
form1.ShowDialog()
End Sub
Private Sub Research_Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Location = New System.Drawing.Point(0,0)
'''###########################-Both Codes work-###########################
' For Each i As ListViewItem In listView1.Items
' i.ForeColor = Color.Green
' i.BackColor = Color.Yellow
' Next
For Each i As ListViewItem In ListView1.Items
If (i.Index Mod 2) = 1 Then
i.BackColor = Color.FromArgb(230, 150, 255)
i.UseItemStyleForSubItems = True
End If
Next
'''###########################-Both Codes work-###########################
End Sub
End Class
Compiler Call From CMD:-
vbc.exe -target:exe [path]\Form1.vb
[path]\Form1.exe