title: Adjust ListView columns to fit with WinForms
body: <p>I have face resize problem of listview columns.  If you <strong>anchor/docking</strong> the listview to normal winform than the listview anchor or docking works well. I mean listview will resize and fit to winforms as winforms maximized but the columns you have designed on it which is not resize with listview.</p>
  
  <p>My question is : <strong>Is there any way to resize the columns of listview with listview to fit winform size?.</strong></p>
  
  <p><strong>Listview Design Code:</strong></p>
  
  <pre><code> private void Form1_Load(object sender, EventArgs e)
      {
  
          listView1.View = View.Details;
          listView1.LabelEdit = true;
          listView1.BackColor = Color.GreenYellow;
          listView1.Columns.Add("Date", 100, HorizontalAlignment.Left);
          listView1.Columns.Add("TransID", 50, HorizontalAlignment.Left);
          listView1.Columns.Add("voucher", 100, HorizontalAlignment.Right);
          listView1.Columns.Add("particulars", 300, HorizontalAlignment.Left);
          listView1.Columns.Add("deposit", 100, HorizontalAlignment.Right);
          listView1.Columns.Add("withdrawal", 100, HorizontalAlignment.Right);
  
          string connstr = "server=.;initial catalog=DataBase;uid=UID;pwd=PWD";
          SqlConnection con = new SqlConnection(connstr);
          con.Open();
          listView1.Items.Clear();
          listView1.Refresh();
          string sql = "select date=convert(varchar,date,103),transID,max(particulars)as particulars,sum(deposit)as deposit,sum(withdrawal) as withdrawal,voucher from debank group by date,transID,voucher";
          SqlCommand cmd = new SqlCommand(sql, con);
          SqlDataAdapter dap = new SqlDataAdapter(cmd);
          DataSet ds = new DataSet();
          dap.Fill(ds);
          DataTable dt = ds.Tables[0];
  
          for (int i = 0; i &lt; dt.Rows.Count; i++)
          {
              DataRow dr = dt.Rows[i];
              ListViewItem lvi = new ListViewItem(dr["date"].ToString());
              lvi.SubItems.Add(dr["transID"].ToString());
              lvi.SubItems.Add(dr["voucher"].ToString());
              lvi.SubItems.Add(dr["particulars"].ToString());
              lvi.SubItems.Add(dr["deposit"].ToString());
              lvi.SubItems.Add(dr["withdrawal"].ToString());
              listView1.Items.Add(lvi);
              listView1.FullRowSelect = true;
  
          }
  
          SizeLastColumn(listView1);
  
  
      }
  </code></pre>