Tag: truncate

如何在C#中截断列表?

我知道在python中你可以做类似myList[1:20]东西,但C#中有类似的东西吗?

字符数减去HTML字符C#

我试图找出一种方法来计算字符串中的字符数,截断字符串,然后返回它。 但是,我需要此函数来不计算HTML标记。 问题是,如果它计算HTML标记,那么如果截断点位于标记的中间,那么页面将显示为已损坏。 这就是我到目前为止…… public string Truncate(string input, int characterLimit, string currID) { string output = input; // Check if the string is longer than the allowed amount // otherwise do nothing if (output.Length > characterLimit && characterLimit > 0) { // cut the string down to the maximum number of characters output = output.Substring(0, […]

如何限制Eval中的文本字符串

我有一个带有如下设置的导航属性的超链接: NavigateUrl=” 如何将字符串限制为140个字符? 我试过这个Eval(“My Text”)。ToString()。Substring(0,140)但是如果字符串长度小于140个字符,它会抛出exception。

C#DataGridView:当列是右对齐时,长文本在左侧以“…”截断

我有一个关于单元格截断的问题(替换为“…”): 当列右对齐时,如何在单元格的左侧显示替换“…”? 我使用非等宽字体,所以我不能只计算字符来做一些字符串操作作为解决方法,我需要一个解决方案。 我相信应该有。 为了说明我的问题,我在这里模拟我的DataGridView Left Context (Right aligned column) | Center Word | Right Context (Left aligned column) left context not truncated | CenterWord | Right context not truncated …Here is the long left context truncated | CenterWord | Here is the long right context truncated… 我想我已经说清楚了。 谢谢。 请帮帮我。 彼得 PS:同样的问题可以在这个链接找到: http : //objectmix.com/csharp/341736-datagridview-cell-format-question.html