Results 1 to 8 of 8

Thread: Listview problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Listview problem

    I am using this code:

    VB Code:
    1. Dim fileUsers As New IO.StreamReader("file.csv")
    2. Dim lineUsers As String()
    3. While fileUsers.Peek() <> -1
    4.   lineUsers = fileUsers.ReadLine().Split(",")
    5.   ListView1.Items.Add(lineUsers(0))
    6. End While

    Now this works fine, except it loads the data into a very short column instead of the full way accross. How can I overcome this?


    Cheers.

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Listview problem

    You need to adjust the width of the appropriate column. Check out the properties of the listview theres a Collums property, click the thingy and you can add and modify them.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  3. #3
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    In A House :)
    Posts
    291

    Re: Listview problem

    in your form load event

    VB Code:
    1. listview1.Columns(0).Width = -1

    -1 sets it to the widest data item
    --"Tap Dancing On The Brittle Edge Of Sanity"--

  4. #4
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Listview problem

    Quote Originally Posted by DirtyHowi
    in your form load event
    VB Code:
    1. listview1.Columns(0).Width = -1
    -1 sets it to the widest data item
    Damn that's good to know.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Listview problem

    Tried both of those, tried setting the width in both code and in the column properties to -1 and to 240 (the width of the ListView item), and it still for some reason displays a little bit accross the way...

    Also for some reason it doesn't show the column heading I have set

  6. #6
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Listview problem

    it seems that you are putting the data in the first column
    try this one
    VB Code:
    1. 'assuming that the firstcolumn name of your listview is columnheader1
    2. 'form load event
    3. this.columnheader1.width=listview1.width-20

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Listview problem

    OK, I found the problem to be with me having

    ListView1.View = Large

    instead of

    ListView1.View = Details


    But now what happens is that I have made 3 columns, the first one has disappeared off to the left when the width properties says it should not...

    Is there any possible reason why the left colum would disappear?

    Cheers.

  8. #8
    Hyperactive Member
    Join Date
    Jul 2005
    Location
    In A House :)
    Posts
    291

    Re: Listview problem

    if you set listview.columns(0).width=-1 it makes that column the width of the widest item, pushing the other columns off to the right. (you said left...which i dont understand, maybe you can enlighten me...never seen that happen before, course never seen a ghost either.) i had the same problem, cept i was only using column(0).

    you can also set the width this way.

    in form load
    listview1.Columns.Add("", 300, HorizontalAlignment.Center)

    change 300 to whatever you want...i was only using one column, so i set it to the width of the control on the screen
    --"Tap Dancing On The Brittle Edge Of Sanity"--

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width