日期:2014-05-18 浏览次数:20915 次
//文本框显示一个0 this.pageNavigation.toolStripTextBox1.Text = "0"; //这是该文本框text值改变时发生事件 void pageNavigation_TextChanged(object sender, EventArgs e) { string pageCount= this.pageNavigation.toolStripTextBox1.Text.Trim(); if (pageCount == "0" || pageCount == "") { this.pageNavigation.toolStripTextBox1.Text = "1"; } else if (int.Parse(pageCount) > this.paging.PageNumber) //this.paging.PageNumber值为0 { this.pageNavigation.toolStripTextBox1.Text = this.paging.PageNumber.ToString(); } } //这样写,这个事件会形成无限循环,请问要怎么改才好?
void pageNavigation_TextChanged(object sender, EventArgs e) { string pageCount= this.pageNavigation.toolStripTextBox1.Text.Trim(); if (pageCount == "0" || pageCount == "") { this.pageNavigation.toolStripTextBox1.Text = "1"; } else(int.Parse(pageCount) > this.paging.PageNumber) //this.paging.PageNumber值为0 { this.pageNavigation.toolStripTextBox1.Text = this.paging.PageNumber.ToString(); } }
------解决方案--------------------
楼主是想让this.pageNavigation.toolStripTextBox1.Text 的值只能为0和1???
void pageNavigation_TextChanged(object sender, EventArgs e) { string pageCount= this.pageNavigation.toolStripTextBox1.Text.Trim(); if (pageCount == "0" || pageCount == "") { this.pageNavigation.toolStripTextBox1.Text = "1"; } else(int.Parse(pageCount) > this.paging.PageNumber) //this.paging.PageNumber值为0 { this.pageNavigation.toolStripTextBox1.Text = this.paging.PageNumber.ToString(); } }