public partial class UserControl1 : UserControl
{
public event EventHandler PageChanged;
private int _PageIndex;
public int PageIndex
{
get { return _PageIndex; }
set
{
if (value < 1)
{
value = 1;
}
if (value>PageCount)
{
value = PageCount;
}
_PageIndex = value;
this.textBox1.Text = _PageIndex.ToString();
if (PageChanged != null)
{
PageChanged(this, null);
}
}
}
public int PageCount { get; set; }
public UserControl1()
{
InitializeComponent();
PageIndex = 1;
PageCount = 10;
this.textBox1.Text = PageIndex.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
PageIndex = 1;
}
private void button2_Click(object sender, EventArgs e)
{
PageIndex--;
}
private void button3_Click(object sender, EventArgs e)
{
PageIndex++;
}
private void button4_Click(object sender, EventArgs e)
{
PageIndex = PageCount;
}
}