您的位置:首页 > 编程语言 > C#

C#列数据、消息框messagebox、文本按指定长度自动换行

2013-06-02 19:08 441 查看
public string dstotring(DataSet ds, int cursor)
{

if (ds.Tables[0].Rows.Count > 0)
{
int count = ds.Tables[0].Rows.Count;
string Caption = string.Empty;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++)
{
sb.Append(ds.Tables[0].Rows[i][0].ToString()).Append(",");
}
Caption = sb.ToString();
StringBuilder sb2 = new StringBuilder();
for (int i = 0; i < Caption.Length; i += cursor)
{
if (i + cursor > Caption.Length)
{
cursor = Caption.Length - i;
sb2.Append(Caption.Substring(i, cursor));
}
else
{
sb2.AppendLine(Caption.Substring(i, cursor));
}
}
return sb2.ToString();
}
return string.Empty;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: