HtmlElement.ClientRectangle 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 HTML 文档中元素工作区的边界。
public:
 property System::Drawing::Rectangle ClientRectangle { System::Drawing::Rectangle get(); };
	public System.Drawing.Rectangle ClientRectangle { get; }
	member this.ClientRectangle : System.Drawing.Rectangle
	Public ReadOnly Property ClientRectangle As Rectangle
	属性值
元素占用的工作区,不包括边框及滚动条占用的任何区域。 若要获得此元素的位置及尺寸(包括其修饰),请改用 OffsetRectangle。
示例
假设已将以下 HTML 页面加载到控件的 WebBrowser 托管实例中。
<HTML>  
    <BODY>  
        <DIV id="div1" style="position:absolute;top:100px;left:100px;border-      style:solid;border-width:1px;">  
            Edit this text.  
        </DIV>  
    </BODY>  
</HTML>  
下面的代码示例演示如何检索此元素并扩展其尺寸(如果工作区宽小于 400 像素,高 50 像素),并且还设置DIV``contentEditable该状态,以便用户可以输入文本。
private void EnableEditing()
{
    if (webBrowser1.Document != null)
    {
        HtmlElement elem = webBrowser1.Document.GetElementById("div1");
        if (elem != null)
        {
            if (elem.ClientRectangle.Width < 200)
            {
                elem.SetAttribute("width", "200px");
            }
            if (elem.ClientRectangle.Height < 50)
            {
                elem.SetAttribute("height", "50px");
            }
            elem.SetAttribute("contentEditable", "true");
            //elem.SetFocus();
        }
    }
}
Private Sub EnableEditing()
    Dim Elem As HtmlElement = WebBrowser1.Document.GetElementById("div1")
    If (Not Elem Is Nothing) Then
        If (Elem.ClientRectangle.Width < 200) Then
            Elem.SetAttribute("width", "200px")
        End If
        If (Elem.ClientRectangle.Height < 50) Then
            Elem.SetAttribute("height", "50px")
        End If
        Elem.SetAttribute("contentEditable", "true")
        Elem.Focus()
    End If
End Sub
	注解
ClientRectangle 将仅返回已分配显式高度和宽度的元素或使用绝对定位的元素的位置数据。 如果文档的位置样式设置为 absolute,则文档绝对处于定位位置,之后该文档可以放置在 HTML 页面上的任何坐标处。