2012-01-04 54 views
0

我有一个HtmlDocument对象加载在winforms应用程序(从Web浏览器对象)。Winforms应用程序中的HtmlDocument,如何判断文本是否溢出?

我在HTML文档中引用特定的html表。

有什么方法可以让我知道该表内的文本是否溢出? (高度或宽度)。

更新

如果我知道我的HTML表格具有200个像素的身高,这将是可以统计的文本和字体大小的行要拿出所需高度的像素高度计内容最近?

回答

1

如果您在HTML表格中指定单元格的宽度和高度(例如200px),那么您可以使用jquery来告诉您单元格大小是否已更改,指示溢出。这个复制到一个HTML文件,并给它一展身手:

<html> 
<head> 
    <script src="http://code.jquery.com/jquery-latest.js"></script> 
</head> 
<body> 

<table border="1"> 
    <tr> 
    <td width="50px">foo00000000000000000000</td> 
    <td width="100px">bar</td> 
    </tr> 
</table> 

Row: <input type="text" value="0"> 
Column: <input type="text" value="0"> 
Width of first cell: <span id="columnWidth">?</span><br> 
</body> 

<script type="text/javascript"> 
    $(function() { 
var row = $('input:first').val(); 
var column = $('input:eq(1)').val(); 
var columnWidth = $('table tr:eq('+row+') td:eq('+column+')').width(); 
$('#columnWidth').text(columnWidth); 
    }); 
</script> 

的foo000000000细胞被指定为50像素,但所有的零就是它溢出到180像素。

相关问题