Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to resize the specific column in TableLayoutPanel dynamically.

Used this code in mousemove event:

C#
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());
   }
}


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...
Posted
Updated 30-Nov-11 18:57pm
v2

1 solution

try this:

C#
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
 
Share this answer
 
Comments
srinivasan_indian 1-Dec-11 1:02am    
Error: Operator '==' cannot be applied to operands of type 'System.Windows.Forms.ColumnStyle' and 'int'

Help me...
[no name] 1-Dec-11 1:16am    
is there any way to get the value of GColumn? if there is, check if it is equal to 1, then proceed. if not, then do nothing
srinivasan_indian 1-Dec-11 1:22am    
Actually I am getting GColumn value through MouseClick event. I wanted to move only the specific column by getting GColumn value like 2 or 3 or 4,whatever it is.

If GColumn is 2, Want to move only 2nd column druing runtme with the help of the above mentioned code..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900