Promote Your Blog
Google

Friday, March 2, 2012

How To Add Selected Items In A ListBox To A ListViewBox

In ListViewBox, each item can have different color and also ListViewBox can display columnar data.

Let us see code to:

  • Access selected items in ListBox
  • Set content & color of item to be added in ListViewBox
  • Clear items, Add items and set display properties of a ListViewBox

Dim sc() As Color = {Color.Blue, Color.Green, Color.Orange, Color.Black, Color.Red, Color.Chocolate, Color.DarkMagenta, Color.DarkKhaki, Color.Crimson, Color.HotPink, Color.Firebrick, Color.Goldenrod, Color.ForestGreen, Color.IndianRed, Color.DarkSalmon}

Form1.ListView1.View = View.Details

Dim ic As Integer = 0

Form1.ListView1.Items.Clear()

For Each it In lstDirList.SelectedItems

Dim x As New ListViewItem

x.Text = it.ToString

x.ForeColor = sc(ic)

Form1.ListView1.Items.Add(x)

ic = ic + 1

Next


No comments:

Post a Comment