private void ColourPanels(Point point) { foreach (Control control in TableLayout.Controls) { control.BackColor = Color.Black; } if (point.X == _dragStart.X && point.Y == _dragStart.Y) { var ctrl = TableLayout.GetControlFromPosition(point.X, point.Y); if (ctrl != null) { ctrl.BackColor = Color.Green; } } else { for (var i = Math.Min(point.X, _dragStart.X); i <= Math.Max(point.X, _dragStart.X); i++) { for (var j = Math.Min(point.Y, _dragStart.Y); j <= Math.Max(point.Y, _dragStart.Y); j++) { var ctrl = TableLayout.GetControlFromPosition(i, j); if (ctrl != null) { ctrl.BackColor = Color.Blue; } } } } }
///<devdoc> ///get the element which covers the specified row and column. return null if we can't find one ///</devdoc> internal IArrangedElement GetControlFromPosition(int column, int row) { return(TableLayout.GetControlFromPosition(Owner, column, row)); }