public partial class Form1 : Form { bool resizing = false; TableLayoutRowStyleCollection rowStyles; TableLayoutColumnStyleCollection columnStyles; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { rowStyles = tableLayoutPanel1.RowStyles; columnStyles = tableLayoutPanel1.ColumnStyles; } private void tableLayoutPanel1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { resizing = true; } } private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e) { if (resizing) { columnStyles[0].SizeType = SizeType.Absolute; rowStyles[0].SizeType = SizeType.Absolute; rowStyles[0].Height = e.Y; columnStyles[0].Width = e.X; } } private void tableLayoutPanel1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { resizing = false; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)