private void button1_Click(object sender, EventArgs e) { string s = "是否要删除以下文件?
"; for (int i = 0; i < 10;i++ ) { s += i.ToString()+".
"; } MessageBox.Show(s, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } |
private void button1_Click(object sender, EventArgs e) { int count = 111; string str = "File"; string s = "是否要删除以下文件?
"; string s1 = ""; if (count < 15) { for (int i = 0; i <= count; i++) { //1.filename s1 += String.Format("{0}.{1}
", i, str); } s = s1; } string s2 = "是否要删除以下文件?
"; if (count > 15) { //产生1...10 for (int i = 1; i < 11; i++) { s2 += String.Format("{0,3}.{1}
", i, str); } s2 += "
"; s2 += " ...
"; s2 += "
"; s2 += s1; //最后一个名称 //s2 += count.ToString() + "." + str; s2 += String.Format("{0,3}.{1}
", count, str); s = s2; } MessageBox.Show(s, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } |