i have a problem. I have a tableLayoutPanel with 2 rows and 2 colums. First colum is empty and in the second colum is something. I know detect a cell which was clicked, but i don't know how can i fill this clicked cell with red collor. Some suggestions? Here is my code:
private void tableLayoutPanel1_MouseClick(object sender, MouseEventArgs e)
{
int row = 0;
int verticalOffset = 0;
foreach (int h in tableLayoutPanel1.GetRowHeights())
{
int column = 0;
int horizontalOffset = 0;
foreach (int w in tableLayoutPanel1.GetColumnWidths())
{
Rectangle rectangle = new Rectangle(horizontalOffset, verticalOffset, w, h);
if (rectangle.Contains(e.Location))
{
MessageBox.Show(String.Format("row {0}, column {1} was clicked", row, column));
return;
}
horizontalOffset += w;
column++;
}
verticalOffset += h;
row++;
}
}