Results 1 to 1 of 1

Thread: Form size based on the number of rows in a Listview

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,437

    Form size based on the number of rows in a Listview

    I just thought I would share this. It's not my code but it helped me do what I wanted. I have a Listview that can have an unknown number of rows at any time and I wanted to make sure the rows were visible (user doesn't have to resize the form to see items). I got a kick out of the code and maybe someone else will too.
    Code:
        Private Sub SetWindowSize()
            If Me.WindowState <> FormWindowState.Minimized Then
                If LstItems.Items.Count = 0 Then Exit Sub
                Dim last = LstItems.Items(LstItems.Items.Count - 1)
                Me.ClientSize = New Size(Me.ClientSize.Width, LstItems.Top + last.Bounds.Bottom + 60)
            End If
        End Sub
    Last edited by jumper77; Sep 21st, 2017 at 04:46 PM.

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