listview question

hi I added listview to my form now after clicking on different buttons I want listview to have different columns. This is my code:

ListView1.Columns.Add("File type", 20, HorizontalAlignment.Left)

ListView1.Columns.Add("Item Column", 20, HorizontalAlignment.Left)

ListView1.Columns.Add("Column 2",20, HorizontalAlignment.Left)

ListView1.Columns.Add("Column 3", 20, HorizontalAlignment.Left)

ListView1.Columns.Add("Column 4", 20, HorizontalAlignment.Center)

ListView1.Refresh()

ListView1.Update()

The problem is that after clicking the button nothing happens I don't see columns names!

What should I change



Answer this question

listview question

  • Malacki

    Tall Dude wrote:

    Your mind goes 'on the blink' on Friday evenings

    Mmmm..... (As the doctor scratches his chin...)

    You're lucky, it happens to me much more often

    Well, it's the excuse I use!!

    Sometimes, those sort of Fridays, start on Monday and last all week!!

    Have a nice weekend.

    james

    aka:Trucker


  • JIM.H.

    Tall Dude wrote:

    Wasn't so much the column widths as

    Me.ListView1.View = System.Windows.Forms.View.Details

    was probably not there.

    (My guess)

    Yes, the view was the main culprit. BUT, the column widths were too small as well. I guess I should have made more mention of the .View not being set. It's Friday evening.........what can I say

    james

    aka:Trucker


  • dzimmy

    Your mind goes 'on the blink' on Friday evenings

    Mmmm..... (As the doctor scratches his chin...)

    You're lucky, it happens to me much more often



  • Dave Foderick

    Wasn't so much the column widths as

    Me.ListView1.View = System.Windows.Forms.View.Details

    was probably not there.

    (My guess)



  • FilthyZombie

    You have your column widths too small. Try this:

    ListView1.View = View.Details

    ListView1.Columns.Add("File type", 100, HorizontalAlignment.Left)

    ListView1.Columns.Add("Item Column", 100, HorizontalAlignment.Left)

    ListView1.Columns.Add("Column 2", 100, HorizontalAlignment.Left)

    ListView1.Columns.Add("Column 3", 100, HorizontalAlignment.Left)

    ListView1.Columns.Add("Column 4", 100, HorizontalAlignment.Center)

    ListView1.Refresh()

    Works good here. the Width does not reflect the number of characters you want in a column. It is an Integer value, but, I have looked to find

    what it reflects but, so far, no luck.

    I'll post back more if I find out.

    james

    aka:Trucker


  • listview question