On clicking a certain cell or row in my table panel layout, the background of that particular row should be highlighted. How do I determine which row has currently been clicked?
Code:protected void CreateTblPnl(object sender, EventArgs e) { (...) tblPnl.Click += new EventHandler(tblPnl_Click); } protected void tblPnl_Click(object sender, EventArgs e) { for (int i = 0; i < tblPnl.ColumnCount; i++) { for (int j = 0; j < tblPnl.RowCount; j++) { Control control = tblPnl.GetControlFromPosition(i, j); if (control.Focus) // Doesnt work!! { tblPnl.BackColor = ColorTranslator.FromHtml("#3A9DCB"); // Ensure only selected row is coloured!! } } } // OR: //TableLayoutPanelCellPosition pos = this.tblPnl.GetCellPosition(e); //Point loc = this.tblPnl.PointToClient(new Point(e.X, e.Y)); //int row = pos.Row; //int col = pos.Column; }




Reply With Quote
