XPTable.Models.Table.GetContainingCell C# (CSharp) Method

GetContainingCell() public method

Returns the cell that contains the given Control (in a ControlColumn). Returns null if the control is not in a valid cell.
If the control is not added to this table.
public GetContainingCell ( Control control ) : Cell
control System.Windows.Forms.Control The control that is part of a Cell.
return Cell
        public Cell GetContainingCell(Control control)
        {
            if (control.Parent != this)
                throw new ArgumentException("Control is not part of this table.", "control");

            Point p = control.Location;
            CellPos cellPos = new CellPos(this.RowIndexAt(p), this.ColumnIndexAt(p));

            if (this.IsValidCell(cellPos))
            {
                // Adjust this to take colspan into account
                // LastMouseCell may be a cell that is 'under' a colspan cell
                CellPos realCell = this.ResolveColspan(cellPos);
                Cell cell = tableModel[realCell];
                return cell;
            }
            return null;
        }
Table