Home » VB.Net

How to add column headers for AxListview control


    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



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")





' 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})




Best regards,
Martin Xie



I have a worksheet "Load" wth over 200 columns.  Want to be able to add a column right after finding specific text contained in row 1.

Sometimes the columns are inserted in order and some times sparatically across the worksheet.

My thought is to set up a Defined name on a sheet called "Table" -  (define name =  "New_Fileds") consisting of two columns - first column is the name to find and the second column is the name to insert column in between and add the text to row 1 of that column.  I am having that table consist of 20 rows (name does not include the header (row 1) like A2:B22.  Of those 20 rows, once Column A is null, then I want to stop the insert.

Defined name = New_Fields.

Row 1:          A1 = Find   Cell B1 = Insert

Row2:          A2 = Radius       B2 = Angle

Row 3:         A3 = Angle        B3 = Depth

Row 4:         A4 = height       B4 = Offset

Rows 5 - 22 do not have data (null)

Starting point is another sheet "Macro".  From this sheet I want to be able to push a macro button, lookup the value in A2 ("New_Fields") go to the sheet "Load" find that value of RADIUS, insert a column and name row 1 of that column ANGLE. 

Then go to A3 ("New_fields") and do the same thing. When come to A5 and the value is null, stop.



When you use  "Alter Table add Column",  it adds the column to the end of the list of fields.

How do you insert the new column to position number 2 for instance given that you may have more than 2 columns?

Create table T1 ( a varchar(20), b varchar(20), c varchar(20))

Alter table add column  x    varchar(20)  

so that  the resulting table is

T1 a varchar(20), x varchar(20), b varchar(20), c varchar(20)

Can this be done programmatically?

You cannot vote on your own post



I have a WPf application which adds columns at run time to an editable grid depending on which data view the user subscribes to.

The code to add the columns is as follows

 DataGridTemplateColumn column = new

column.Header = field.Caption;
column.IsReadOnly = !(this
.IsReadOnly || !field.IsEditable);
column.HeaderStyle = GetStyle(field.HeadingAlignment, true
column.CellStyle = GetStyle(field.CellAlignment, false

// Create a factory. This will create the controls in each cell of this column as needed.

FrameworkElementFactory comboBoxElement =


comboBoxElement.SetValue(ComboBox.ItemsSourceProperty, field.ValueDictionary);

comboBoxElement.SetValue(ComboBox.SelectedValuePathProperty, "Key"
comboBoxElement.SetValue(ComboBox.DisplayMemberPathProperty, "Value"

binding = new
, field.Index));
comboBoxElement.SetValue(ComboBox.SelectedValueProperty, binding);

// Create the template itself, and add the factory to it.

DataTemplate cellTemplate = new
cellTemplate.VisualTree = comboBoxElement;

column.CellTemplate = cellTemplate;



The grid is created programmatically as are all its columns.

This method is called when the grids datasource is changed. using a custom dictionary object named field I supply all the schema info to add the new column to the grid.

Unfortunately the combobox below is only filling a portion of the column it is added to.

I need to set the minwidth of the Data template combobox control to the width of the column header.

My problem is the header is also set at runtime so I need to be able to measure the column header and set the comboBox width as the same.


Any suggestions would be helpful as I have spent all day at this and no luck yet





Table Page break does not work in vs 2010 rdlc also Repeat Header Rows on each page does not work and the header row does not repeated on new pages.

both of them do correctly in vs 2008.


So Thanks inadvance



I whant to add another header in report.


         Name         LastName              Store

     +    test             test1                     a 

            text             text                                  New Frozen header

               a               b                         c  

     +     test1          test2                      b 

             text             text                                  New Frozen header

               d                 e                        f



I have some code which adds image to the document body but now the requirement is to add the image as part of the header. To do that I used Open XML SDK 2.0 productivity tool and gave the source as the file without the header and gave the target of file with the header. It created a long ...long code for me..it did work earlier but now giving some issues.

I was wondering isn't there any simple and small lines of code to generate header and add image to the header?...or the only choice it so use this tool?

Also I am using VS 2008 and the language is C#

Kindly advice.



Hi All,


          How to display dynamic  header for datalist control(Dates are dynamic).Also i want header in each row.I want something like this.Words in bold are headers.Header also in each row.8/1/2010,8/8/2010,8/15/2010,8/22/2010 are dynamic dates whic changes every month based on user selecting date from datecontrol.


      HeadCount       8/1/2010       8/8/2010      8/15/2010     8/22/2010

 Forecaster HC         447                  446                       441            432

Agents Scheduled   447                  446                       441           432





Hi - I am working on my first SSRS report and I have mostly all of it down except one issue. Per requirements, I need to display a column that is a non header column to repeat on every page while printing and or when I save the generated report in SSRS as a PDF file. I have seen some previous blog from 2007 where RepeatWith property is recommended to be set to the same name of the Tablix in which the column(s) are embeded, tried that but it is not working.

Can any one help me on this or guide me how to resolve this?






i have a grid view and i use TemplateField.

when i am in ItemTemplate all the column (7 column) are label so it fit to the current screen

by when i use EditItemTemplate or InsertItemTemplate the coulmn don't fit the the current screen and

i have to use the ruler in order to see more information about the cell (which is ok - because in each cell i have a dropdownlist or long textbox)

but when i drag the ruler to the right size to see more information only the cells are moved but the header coulmn stay

so i see the current coulmn with worng header coulmn


please your help



Our company is building a word add-in (document-level add-in) with visual studio 2010, word 2007 and VSTO 3.0 sp1. We found strange behavior regarding changing tables and controls in those changed tables. So we created this simple POC project to show this issue and to ask for possible workarounds.

POC code:

We have two classes. PocRibbon class and ThisDocument class.






     PrivateSub btnInsertControl_Click(ByVal sender As System.Object , ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs ) Handles btnInsertControl.Click

        Dim document AsThisDocument = Globals .ThisDocument

        ' Get position point of the control:

        Dim positionOfElement AsInteger = document.Application.Selection.Start

         ' Insert content control:

        Dim controlInterop As Interop.Word.ContentControl = document.ContentControls.Add(WdContentControlType .wdContentControlText, _

                                                                                   document.Range(positionOfElement, positionOfElement))

        controlInterop.Tag = "controlName"

        Dim controlTools AsPlainTextContentControl = document.Controls.AddPlainTextContentControl(controlInterop, controlInterop.Tag)





     PrivateSub ThisDocument_ContentControlBeforeDelete() HandlesMe .ContentControlBeforeDelete

        MsgBox("Control is Deleted!" )

         ' In original code, here control's Tools object and event handlers are deleted for this control.


     PrivateSub ThisDocument_ContentControlAfterAdd() HandlesMe .ContentControlAfterAdd

        MsgBox("Control is Added!" )

         ' In original code, here is control's Tools object recreated and handlers readded.



In ribbon this document-level add-in has one button – btnInsertControl . When user clicks on this button, empty plain text control is inserted into document on current cursor location. This only works correctly if current selection is in main document part, not in header or footer.


In ThisDocument class we have two simple event handlers that only notify user about events (Document.ContentControlBeforeDelete and Document.ContentControlAfterAdd ).


Scenario that will display the issue is following:

·         Insert table into the document. ·         Place selection into one table cell. ·         Click Insert control button from ribbon (control will be inserted into the cell you have selected, Event ContentControlAfterAdd is raised ). ·         Change table by adding new column into it (Event ContentControlBeforeDelete is raised )


It looks like adding new columns into a table means that table will be deleted and replaced with new one that will have all content of old table instead of editing existing one. It means Word will remove content controls and add new ones too. Problem escalates because, after this happens, event ContentControlBeforeDeleteis raised but ContentControlAfterAddis not. So this newly added control is “dead” control, because only Interop object is added by Word but not its Tools object and event handlers as well. In original code ContentControlAfterAddevent handler is used to “revive” readded controls (on Undo/Redo for example) by adding control’s Tools object and old event handlers.


Anyone has an idea how to recognize these events or can propose any workarounds?


Best regards,



Hi all,

I need to develop a feed back list using a custom list in SharePoint .In that list I have certain cloumns in which I will ask the rating from the user and comments.I have made a choice column for the rating and I am unable to implement the comments section which typically include Text Area.My Problem is How could I make in SharePoint that both Rating and Text Area Appear in site column so that the user can enter his rating and comments for each column.


I had the same problem as others where the tablix header will not repeat on multiple pages of the report. 
I followed the instructions here http://blogs.msdn.com/robertbruckner/archive/2008/10/13/Repeat-Header-And-Visible-Fixed-Header-Table.aspx and it did not solve the problem.  After trying several scenarios, I found that it was not repeating because I have each header value in a rectangle which spans one column, rather than having each header value in it's own tablix column.

For instance, if we have fields CompanyID and CompanyName on the report, the repeating headers work if I have them in separate columns like this:

                              Tablix Column 1  |  Tablix Column 2
Tablix Header row    Company ID        |  CompanyName
Tablix Detail row      [CompanyID]      |  [CompanyName]

It DOES NOT work when it is designed like this:

                             Tablix Column 1
Tablix Header Row   Company ID    Company Name  (two textboxes in a rectangle)
Tablix Detail Row    [CompanyID]   [CompanyName]  (two textboxes in a rectangle)

Additional info
We have about 1000 reports designed this way that we originally designed in Reporting Services 2005.  We upgraded to 2008 and the reports are displayed just fine except for this issue with the header repeating on multiple pages.  Is there any way to resolve this WITHOUT having to redesign all of these reports?

Thank you,


I've created a custom control, however, as a direct "Forms.UserControl" I can't seem to be able to "add" child controls to it.  So I've inherited from Panel instead, which worked, however, I'm adding controls to the "Panel" not to the "GroupBox" contained within the User Control. 


How would I (Using Panel or UserControl as the Parent Class for Inheritance) add a GroupBox to the control, and subsequently allow the Forms designer to add a Control (like a checkbox) to the GroupBox control contained within Me.Controls for the custom control?

Basically, I drop UserGroupBox1 onto the form, and then on the same form drop a CheckBOx1 onto the UserGroupBox1 which adds it to the GroupBox contained within.  How do i do that in the UserGroupBox1 control creation?


Jaeden "Sifo Dyas"

Hi All,

   I have a drill down report created using SSRS, but the issue I have is that the columns that appear after I click on toggle, the header is always visible and is aligned with the main Header. The requirement I have is that I have to make the Header invisible as the column and when I click on Toggle then the column and the Header of the Student has to be visible under th eMain Header and column Program. 

 - Program Name| Type | Details....

      Student | Stu. Address | Details...

The above is the design I neeed to achieve with SSRS. Please respond if you know the solution.

Thank you.

(Using BIDS 2008 R2)

OLEDB/ADO Destionation

Reuse input column
Is there any way to map a input column to two destination columns?

State static value instead of mapping column
I have a package for each version of the production system - they insert in the same destination tables - I just need to add a version number to the version column - like '2.1' and '3.0'. The only way I have found so far is to select a fake column in the source like select '2.2' as Version, ..- This is however not very smart when I'm selecting millions of rows.

I would just like to be able to type in a static value instead of mapping a column - any way to do this?


Hi all,

Simple data import, reading in a flat file, doing a data conversion on the fields, inserting to table in database.

However, when I use the FLOAT type in my data conversion, even though the source data has only 5 places after the decimal, the resulting data in the table has up to 20 places after the decimal (??).

Adding a data view after the conversion process, I can see that the data is visually OK, only showing 5 decimal places.

I finally got around this by changing FLOAT type to a STRING and letting the server do the conversion...

Still, I'd like to know why when I (thinking correctly?) added the data conversion component and (correctly?) set the field type to FLOAT to match the table, that the extra decimals got added.

Thanks in advance


 I need to make a link for all the rows in one column of a gridview(VB .Net) where the grid has been auto-created from the data source. The link would simply point to another ASP details web page. The examples I have found have all been in C# and I don't quite follow them.





Can anyone help me with the sample code to programatically add the "SummaryLinks" type column to the Site columns list.


When I click the on the "Add From Existing Site COlumns" link on my newly created content type I receive an error message.  I cannot locate what this error message means or why it is occuring.  Any ideas??

Error Message
Specified argument was out of the range of valid values.
Parameter name: name   at Microsoft.SharePoint.WebControls.GroupedItemPicker.AddItemHtml(String id, String name, String descriptionHtml, String group)
   at Microsoft.SharePoint.WebControls.GroupedItemPicker.AddItem(String id, String name, String description, String group)
   at Microsoft.SharePoint.ApplicationPages.AddFieldToContentTypePage.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Hello Friends,

I am trying to create a column that takes another column value from the same source table as input and creates a hyperlink, so that, my clients can simply click on the link and be able to view the details from on internet browser from a different database..

can I use this as an update queryto acieve the above?



[CUstomerEncountered BURTS-Case_and_BU_mappings]



[BURT-LINK] =N'[ http://burtweb.eng.company.com:8080/burt-bin/start?burt-id=[BugNo]'

(FYI- BugNo - is another column existing in the same table)

If so, what should be the data type for BURT-LInk column? There seem to be no Hyperlink data type in sqlserver that I could choose from.

Appreciate your help


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure