C# 在字符串中添加“\r”换行符 实现lable自动换行
来源:互联网 发布:秦国为何灭亡 知乎 编辑:程序博客网 时间:2024/05/23 01:23
按字节截取字符串,并在规定位置添加换行符【\r】,解决lable自动换行问题
public static string CutString(string inputString)
{
ASCIIEncoding ascii = new ASCIIEncoding();
int len = 30;
int tempLen = 0;
int j=0;
string newstr = ""; ;
string tempString = "";
string[] str_temp = new string[10];
byte[] s = ascii.GetBytes(inputString);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
try
{
tempString += inputString.Substring(i, 1);
}
catch
{
break;
}
if (tempLen > len)
{
tempString = tempString + "\r";
str_temp[j] = tempString;
tempLen = 0;
tempString = "";
j++;
}
}
str_temp[j] = tempString;
for (int l = 0; l <= j; l++)
{
newstr = newstr + str_temp[l];
}
return newstr;
}
- C# 在字符串中添加“\r”换行符 实现lable自动换行
- ios Lable 自动换行
- C#字符串换行--\r\n
- MFC 按字节读取字符串 添加换行符 实现static text自动换行
- UITableView中Lable自动换行,Cell自动适应高度
- WinForm开发中使用Lable自动换行的问题
- WinForm开发中使用Lable自动换行的问题
- Lable换行
- 在minicom中自动换行
- 在DIV中自动换行
- 内容按现有宽度 lable自动换行
- 关于Lable自动换行的问题
- ios Lable自适应高度、自动换行
- Flex中实现自动换行
- C#自动换行公共类--字符串处理
- C#中TextBox实现换行
- C#中TextBox实现换行
- C#中TextBox实现换行
- jquery 表格的增加删除和修改及设置奇偶行颜色
- Emacs 之 ediff 学习
- 《找你妹》爆红:接地气 用户被“你妹”吸引
- 手机滑动焦点图,滑屏
- IOS uiview一个动画的使用 写了个测试记忆力的
- C# 在字符串中添加“\r”换行符 实现lable自动换行
- .Net常见面试题整理(二)——装箱和拆箱
- 中国首创新一代交流LED白光照明光源技术
- .net 导出复杂格式的EXCEL
- arm-eabi-gcc: : No such file or directory编译错误
- Spring + Struts +Hibernate
- To kernel driver monitoring process developed in Windows8 create using Visual studio2012
- CareerCup 1.6
- centos6.3 eclipse c/c++ launch failed no binaries