How to arrange control like textbox below listview.columns.[]? . I think listview.columns doesn't have any property or method for arrange other controls exact below listview columns.
It is require when your form and other control including Listview are resizable.
I have Following example :
Listview1
Columns(1) (Amount1) Columns(2)(Amount2) Columns(3)(Amount3)
1000 2000 3000
And I wants textBox1,textBox2 and textBox3 Exact Below Listview and Resizable as per listview Columns. How to do it?.

FroglegRank #1,020 · 1.9K reputationPosted Jun 2, 2011, 12:42 PM EDT
namespace ListviewTxtBox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listView1.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
setColumns();
}
public void setColumns()
{
listView1.Columns[0].Width = (listView1.Width / 3)- 2;
listView1.Columns[1].Width = (listView1.Width / 3) - 2;
listView1.Columns[2].Width = (listView1.Width / 3) - 2;
textBox1.Width = (listView1.Width / 3) - 10;
textBox2.Width = (listView1.Width / 3) - 10;
textBox3.Width = (listView1.Width / 3) - 10;
textBox1.Top = listView1.Height + 20;
textBox2.Top = listView1.Height + 20;
textBox3.Top = listView1.Height + 20;
textBox1.Left = listView1.Left + 5;
textBox2.Left = listView1.Left + textBox1.Width + 15;
textBox3.Left = listView1.Left + (textBox1.Width * 2) + 25;
}
private void Form1_Resize(object sender, EventArgs e)
{
setColumns();
}
}
}
Anchoring the textboxes the same as the listview did'nt work
mahesh waghela88 reputationPosted Jun 3, 2011, 5:00 AM EDT
Frogleg
Nice Solution and it is work very well. Here I have generate the easy way which I would like to share with the community is as under:
private void Controls_Size()
{
textBox3.Width = listView1.Columns[5].Width;
textBox2.Width = listView1.Columns[4].Width;
textBox4.Width = listView1.Columns[6].Width;
textBox5.Width = listView1.Columns[7].Width;
textBox2.Left = listView1.Width - listView1.Columns[7].Width - listView1.Columns[6].Width - listView1.Columns[5].Width - listView1.Columns[4].Width-12;
textBox3.Left = listView1.Width - listView1.Columns[7].Width - listView1.Columns[6].Width - listView1.Columns[5].Width-10;
textBox4.Left = listView1.Width - listView1.Columns[7].Width - listView1.Columns[6].Width-7;
textBox5.Left =listView1.Width - listView1.Columns[7].Width-6;
}
and the same also working very well for me. But I hereby accept your answer for first preference. once again thanks.
Sam HobbsRank #107 · 20.5K reputationPosted Jun 3, 2011, 4:39 PM EDT
mahesh waghela88 reputationPosted Jun 4, 2011, 8:12 AM EDT