Home » VB.NetRSS

How to add column headers for AxListview control

Hi,

    We are migrating vb6.0 project to vb.net. Here we are using AxListView control instead of Vb6.0 Listview. We are trying to add ColumnHeaders for that list view.it is giving me error saying "This item's control has been deleted." . Please anybody help me.

 

Thanks in advance

Susanthi

 

2 Answers Found

 

Answer 1

The VB 6.0 ListView control  is converted to AxListView when the application is ported to .NET. Is there any reason that you are not using the .NET ListView control?
 

Answer 2

By the way, here is one code sample: How to make .NET ListView control  with ColumnHeader and Group features?

Prerequisites: Drag&drop ListView1 onto Form1.

PublicClass Form1

 

PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

 

ListView1.View = View.Details

'ListView1.CheckBoxes = True

 

' Create 1 columns and add  them to ListView

Dim columnHeader0 As ColumnHeader = New ColumnHeader()

columnHeader0.Text = "Type"

columnHeader0.Width = 200

ListView1.Columns.AddRange(New ColumnHeader() {columnHeader0})

 

' Create two groups and add them to ListView

Dim group1 As ListViewGroup = New ListViewGroup("Fruit")

Dim group2 As ListViewGroup = New ListViewGroup("Vegetable")

 

ListView1.Groups.Add(group1)

ListView1.Groups.Add(group2)

 

' Create 4 items  and add them to ListView

Dim item1 As ListViewItem = New ListViewItem(NewString() {"Mango"}, 0, group1)

Dim item2 As ListViewItem = New ListViewItem(NewString() {"Coconut"}, 0, group1)

Dim item3 As ListViewItem = New ListViewItem(NewString() {"Carrot"}, 1, group2)

Dim item4 As ListViewItem = New ListViewItem(NewString() {"Cabbage"}, 1, group2)

ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3, item4})

EndSub

 

EndClass



Best regards,
Martin Xie

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter