HtmlDocument2 of HTMLEditor Class object description

Source: Internet
Author: User

HtmlDocument2 HTML Document Object model:

The main methods are:

      1. GetBody () Gets the current document body object
      2. GetReadyState () Gets the current document state information, such as whether it is loading, has completed, and the enumeration value is: Uninitialized,loading,loaded,interactive,complete
      3. ExecCommand () Executes the command, such as ExecCommand ("Multipleselection", false, true); Indicates that the current document allows multiple-selection controls
      4. GetSelection () Gets the current selection area, which is used for two scenarios:

Scenario 1: Use to insert HTML code at the currently selected location.

     var  as IHTMLTxtRange;          if NULL {         selrange.pastehtml ("<input type= ' text '/>");        }

Scenario 2: Get the currently selected control

     var  as Ihtmlcontrolrange;      if (controlrange!=null) {                  var length = controlrange.getlength ();                  for (int0; i < length;i++ )                {                    var control = Controlrange.item (i);                }     }

5.GetStyleSheets () Get style sheet, style settings

IHTMLStyleSheetsCollection sheets = currentdocument.getstylesheets ();//Get style sheetIHTMLStyleSheet sheet =NULL; if(Sheets.length = =0)//style sheet length is 0, the new{Sheet= Currentdocument.createstylesheet ("",0); }            Else //greater than 0, gets the first style sheet            {                Objecti =0; Sheet= Sheets.item (refI asIHTMLStyleSheet; } Commonargs args=NewCommonargs (); Args. Tag= Sheet. Getcsstext ();//gets the style of the current style sheetHtmlviewcssstyleeditform Styleform =Newhtmlviewcssstyleeditform (args); if(Styleform. ShowDialog () = =DialogResult.OK) {Try{sheet. Setcsstext (args. Tag.tostring ());//Set Style_currentformdesignformmodel.viewstylerules.clear (); IHTMLStyleSheetRulesCollection Rules=sheet.                    GetRules ();  for(inti =0; I < rules. GetLength (); i++)                    {                        varRule =rules. Item (i).                        Getselectortext (); if(rule. Length >1&& rule. StartsWith ("."))                        {                            varGcistylerule =NewGcistylerule (); Gcistylerule.name= Rule. Substring (1); Gcistylerule.ruletext=rules. Item (i). GetStyle ().                            Getcsstext ();                        _currentformdesignformmodel.viewstylerules.add (Gcistylerule); }} _currentformdesignformmodel.currentview.viewcssstyle=args.                Tag.tostring (); }                Catch(Exception ex) {}}

HtmlDocument2 of HTMLEditor Class object description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.