示例#1
0
        public IHTMLElement Row_InsertCell(mshtml.IHTMLTableRow row, int index)
        {
            IHTMLElement elem = row.insertCell(index) as IHTMLElement;

            if (elem != null)
            {
                elem.innerHTML = " ";
            }
            return(elem);
        }
示例#2
0
        /// <summary>
        /// Method to determine if the current selection is a table
        /// If found will return the table element
        /// </summary>
        private void GetTableElement(out mshtmlTable table, out mshtmlTableRow row)
        {
            row = null;
            mshtmlTextRange range = GetTextRange();

            try
            {
                // first see if the table element is selected
                table = GetFirstControl() as mshtmlTable;
                // if table not selected then parse up the selection tree
                if (table.IsNull() && !range.IsNull())
                {
                    var element = range.parentElement();
                    // parse up the tree until the table element is found
                    while (!element.IsNull() && table.IsNull())
                    {
                        element = element.parentElement;
                        // extract the Table properties
                        var htmlTable = element as mshtmlTable;
                        if (!htmlTable.IsNull())
                        {
                            table = htmlTable;
                        }
                        // extract the Row  properties
                        var htmlTableRow = element as mshtmlTableRow;
                        if (!htmlTableRow.IsNull())
                        {
                            row = htmlTableRow;
                        }
                    }
                }
            }
            catch (Exception)
            {
                // have unknown error so set return to null
                table = null;
                row = null;
            }
        }