动态移动特定列 [英] Moving specific column dynamically
本文介绍了动态移动特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想动态调整TableLayoutPanel
中特定列的大小.
在mousemove事件中使用了以下代码:
I want to resize the specific column in TableLayoutPanel
dynamically.
Used this code in mousemove event:
private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
try
{
if (resizing)
{
columnStyles[GColumn].SizeType = SizeType.Absolute;
columnStyles[GColumn].Width += e.X - columnStyles[GColumn].Width;
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
}
}
如果我将GColumn的值设置为2,则它正在完美地移动第二列.但是它也在移动第3、4列.我只想移动第二列.
帮助我解决这个问题...
If i set GColumn value is 2, it is moving 2nd column perfectly. But it is moving 3rd,4th column as well. I wanna move only 2nd column..
Help me for this issue...
推荐答案
尝试一下:
try this:
private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
try
{
if (resizing)
{
if(columnStyles[GColumn] == 1) // index for 2nd column
{
columnStyles[GColumn].SizeType = SizeType.Absolute;
columnStyles[GColumn].Width += e.X - columnStyles[GColumn].Width;
}
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
}
}
如果这解决了您的问题,请标记为答案
否则,让我知道
问候,
爱德华
Please mark as answer if this solved your problem
else, let me know
Regards,
Eduard
这篇关于动态移动特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文