0

Good day Fellow SO users,

I hope you can help me with my problem.

I've got a VB.NET application, with ListView for SerialNumbers.

The length of SerialNumbers are different from each other.

Users need to check for accuracy, and it's tedious for them to hover on each SerialNumber to check. Image below is the ListView without resizing.

enter image description here

After some research and testing, I've come up with resizing code

For i = 250000 To 250100 'Loop for filling dummy serial numbers

    Dim sn As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ" & i 'Dummy long Serial Number
    lvSerial.Items.Add(New ListViewItem(sn, Group)) 'Add the dummy SN to the list
    lvSerial.TileSize = New System.Drawing.Size(sn.Length * 8, 20) 'Resize the ListViewItem with length based on sn length * 8, height is fixed 20
Next i
For i = 100 To 200
    Dim sn As String = "ABC" & i 'Dummy short serial number
    lvSerial.Items.Add(New ListViewItem(sn, Group))
Next i

and I got this..

enter image description here

My problem is, for the short serial numbers, it consumes too much rows because it took the length of the long one.

It seems that TileSize applies for all ListViewItem and not individually.

Is there any way to make my ListViewItem be 'autosized' or 'autofit'?

Thanks in advance.

CurseStacker
  • 1,387
  • 8
  • 19
  • How could individual items autosize when they're supposed to be in columns? – jmcilhinney Mar 20 '15 at 04:12
  • Your point being?.. My ListView is in Tile view. – CurseStacker Mar 20 '15 at 04:57
  • If you use ListView.View = List .. the header row will be as large as the longest serial, play with .View = Tile, or other .. but you can show the small serial in other ListView right under the Long Serials .. – CristiC777 Mar 20 '15 at 12:45
  • or Use ListView with 2 columns .. http://www.dotnetheaven.com/article/listview-control-with-multiple-column-in-vb.net – CristiC777 Mar 20 '15 at 12:47
  • http://stackoverflow.com/questions/11482501/populating-a-listview-multi-column – CristiC777 Mar 20 '15 at 12:48
  • or add a filter with 6-8 chars to show you just some serials, relevant to waht operator wants from that ListView, I don't thnik a ListView with 250K rows is relevent or usable for someone .. – CristiC777 Mar 20 '15 at 12:51

0 Answers0