Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I tried tablelayoutpanel control using c#. But i am not succeed with some requiremnets. So that I need some other new control to meet all my requirements.


Requirements are,

1. Want to move specific column or row during runtime.
2. Set the backcolor for more than one cells and show the background text.

These requirements should be meet with my new control.Help me to create like this..
Posted

1 solution

Your question lacks some detail, but it sounds like you need to look at the DataGridView[^] class.
 
Share this answer
 
Comments
srinivasan_indian 6-Dec-11 6:08am    
I will place my code used for tablelayoutpanel to

1. Get the row and column values during mouse_click event

2. With the help of that values, user can move the rows and columns.

Requirement:

I want to move only the particular column,but it is moving the particular column as well as the next column.

Hope you understand my issue..Code:

private void tableLayoutPanel1_MouseDown(object sender, MouseEventArgs e)

{ if (e.Button == System.Windows.Forms.MouseButtons.Left)

{ resizing = true; }

} int GRow = 0; int GColumn = 0;

private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e)

{ try { if (resizing)

{ if (rbColumn.Checked) {



tableLayoutPanel1.Cursor = Cursors.VSplit;

columnStyles[GColumn].SizeType = SizeType.Absolute;

columnStyles[GColumn].Width += e.X - columnStyles[GColumn].Width;

} else

{

tableLayoutPanel1.Cursor = Cursors.HSplit;

rowStyles[GRow].SizeType = SizeType.Absolute;

rowStyles[GRow].Height += e.Y - rowStyles[GRow].Height;

} }

} catch (Exception ex)

{ //MessageBox.Show(ex.ToString()); }

}

private void tableLayoutPanel1_MouseUp(object sender, MouseEventArgs e)

{ if (e.Button == System.Windows.Forms.MouseButtons.Left)

{ resizing = false;

tableLayoutPanel1.Cursor = Cursors.Default; }

}

private void tableLayoutPanel1_MouseClick(object sender, MouseEventArgs e)

{
try
{
int Row=0;

int VSpace = 0;

foreach (int h in tableLayoutPanel1.GetRowHeights())

{
int Column=0;

int HSpace = 0;
foreach (int w in tableLayoutPanel1.GetColumnWidths())
{
Rectangle Rect = new Rectangle(HSpace, VSpace, w, h);
if ((Rect.Contains(e.Location)))
{
GColumn = Column; GRow = Row;
RColumn = Convert.ToString(GColumn) + ',' + Convert.ToString(GRow); MessageBox.Show("Row Value = " + Row.ToString() + " " + "Column Value = " + Column.ToString(), "TableLayoutPanel", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
HSpace += w;
Column += 1;
}
VSpace += h;
Row += 1;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Richard MacCutchan 6-Dec-11 7:00am    
This would be much better (and readable) pasted into your original question; use the Improve question link.

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