C # WINFORM问题
文本框左右各有一个按钮,单击左侧按钮则文本框中文字向左循环滚动一次,单击右侧按钮则文本框中文字向右循环滚动一次求代码:privatevoidbutton1_Click(o...
文本框左右各有一个按钮,单击左侧按钮则文本框中文字向左循环滚动一次,单击右侧按钮则文本框中文字向右循环滚动一次
求代码:
private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text;
char frist = str[0];
string end = str.Substring(1);
textBox1.Text = end + frist;
}
private void button2_Click(object sender, EventArgs e)
{
string str2 = textBox1.Text;
string frist2 = str2.Substring(0, str2.Length - 1);
char end2 = str2[str2.Length];//我的这句有什么问题 求正确的代码
textBox1.Text = end2 + frist2;
谢谢各位拉 展开
求代码:
private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text;
char frist = str[0];
string end = str.Substring(1);
textBox1.Text = end + frist;
}
private void button2_Click(object sender, EventArgs e)
{
string str2 = textBox1.Text;
string frist2 = str2.Substring(0, str2.Length - 1);
char end2 = str2[str2.Length];//我的这句有什么问题 求正确的代码
textBox1.Text = end2 + frist2;
谢谢各位拉 展开
2个回答
展开全部
private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
if (string.IsNullOrEmpty(str)) return;
if (str.Length == 1) return;
char first = str[0];
string end = str.Substring(1);
textBox1.Text = end + first;
}
private void button2_Click(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
if (string.IsNullOrEmpty(str)) return;
if (str.Length == 1) return;
string first = str.Substring(0, str.Length - 1);
char end = str[str.Length - 1];
textBox1.Text = end + first;
}
{
string str = textBox1.Text.Trim();
if (string.IsNullOrEmpty(str)) return;
if (str.Length == 1) return;
char first = str[0];
string end = str.Substring(1);
textBox1.Text = end + first;
}
private void button2_Click(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
if (string.IsNullOrEmpty(str)) return;
if (str.Length == 1) return;
string first = str.Substring(0, str.Length - 1);
char end = str[str.Length - 1];
textBox1.Text = end + first;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询