שתף באמצעות


Listview control with no column header ?

Question

Thursday, March 28, 2013 2:22 PM

I am using VB.NET 2010.
Can I have a Listview control that has 2 columns, but with no column header, in other words, I just want to list the items without the heading ?

Thank you

All replies (10)

Thursday, March 28, 2013 2:49 PM | 1 vote

No, because of the quote below from Listview.View property page on MSDN

"If your ListView control does not have any column headers specified and you set the View property to View.Details, the ListView control will not display any items. If your ListView control does not have any column headers specified and you set the View property to View.Tile, the ListView control will not display any subitems."

You can use datagridview control where you can hide the header by set the ColumnHeadersVisible to False

dataGridView1.ColumnHeadersVisible = False

kaymaf

CODE CONVERTER SITE

http://www.carlosag.net/Tools/CodeTranslator/.

http://www.developerfusion.com/tools/convert/csharp-to-vb/.


Thursday, March 28, 2013 3:00 PM

A datagridview is the solution, but if you must use a listview, you can set the column width to 0


Thursday, March 28, 2013 5:51 PM

You want to discuss this, no I don't think so.

Success
Cor


Thursday, March 28, 2013 7:05 PM

Use a ListBox and do your own drawing.


Thursday, March 28, 2013 7:49 PM

Thank you all.

@Stephan Arsenault: If I set the column width to 0, it won't show the items in the rows below it, right ?
I want to show the items in the rows, just not the column heading.
Instead of this
col1 col1
a 1
b 2

I want to show this (no column heading)
a 1
b 2


Thursday, March 28, 2013 8:26 PM | 4 votes

Hi aujong,

All you need to do is set the (headerstyle  = None). I just tried it and it works fine for me.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        ListView1.HeaderStyle = ColumnHeaderStyle.None

        'This was just to fill the 2 columns for this test
        For x = 1 To 6
            Dim lvi As New ListViewItem("Column 1")
            lvi.SubItems.Add("Column 2")
            ListView1.Items.Add(lvi)
        Next
    End Sub


Thursday, March 28, 2013 10:24 PM | 1 vote

Change the thread type to Question and mark IronRazerz's  response as answer.


Wednesday, April 11, 2018 2:35 AM

Go to properties and set HeaderStyle to None..


Thursday, April 12, 2018 6:39 PM

I am using VB.NET 2010.
Can I have a Listview control that has 2 columns, but with no column header, in other words, I just want to list the items without the heading ?

Thank you

How is this a discussion and not a question?

La vida loca


Thursday, April 12, 2018 7:53 PM | 1 vote

Go to properties and set HeaderStyle to None..

 That is the same answer that I already gave in the second post up from your post.  8)

If you say it can`t be done then i`ll try it