using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Wizard { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { UpdateButtons(); } void UpdateButtons() { if (sftTabs1.Current == 3) { // on this page we honor the check boxes buttonNext.Enabled = checkBoxNext.Checked; buttonBack.Enabled = checkBoxBack.Checked; } else { // otherwise enable back/next buttonBack.Enabled = sftTabs1.Current > 0; buttonNext.Enabled = true; } } private void buttonBack_Click(object sender, EventArgs e) { --sftTabs1.Current; } private void buttonNext_Click(object sender, EventArgs e) { if (sftTabs1.Current == sftTabs1.Count - 1) { // on the last page we exit Application.Exit(); } else { // otherwise just go to the next tab label ++sftTabs1.Current; } } private void sftTabs1_Switched(object sender, EventArgs e) { // a new tab page is active // update next/back button status UpdateButtons(); // update Next/Finish button caption if (sftTabs1.Current == sftTabs1.Count - 1) { // we have reached the last page buttonNext.Text = "&Finish"; } else { buttonNext.Text = "&Next >"; } } private void buttonCancel_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("Are you sure you want to quit?", "Wizard", MessageBoxButtons.YesNo)) Application.Exit(); } private void checkBoxNext_CheckedChanged(object sender, EventArgs e) { UpdateButtons(); } private void checkBoxBack_CheckedChanged(object sender, EventArgs e) { UpdateButtons(); } private void buttonStart_Click(object sender, EventArgs e) { sftTabs1.Current = sftTabs1.TabCollection["First"].Index; } private void buttonEnd_Click(object sender, EventArgs e) { sftTabs1.Current = sftTabs1.TabCollection["Last"].Index; } } }