Anagrams.Form1.listView1_Resize C# (CSharp) Method

listView1_Resize() private method

private listView1_Resize ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void listView1_Resize(object sender, EventArgs e)
        {
            // trial and error shows that we must make the column
            // header four pixels narrower than the containing
            // listview in order to avoid a scrollbar.
            listView1.Columns[0].Width = listView1.Width - 4;

            // if the listview is big enough to show all the items, then make sure
            // the first item is at the top.  This works around behavior (which I assume is
            // a bug in C# or .NET or something) whereby
            // some blank lines appear before the first item

            if (listView1.Items.Count > 0
                &&
                listView1.TopItem != null
                &&
                listView1.TopItem.Index == 0)
                listView1.EnsureVisible(0);
        }