Wednesday, February 18, 2009

Wizard Control in WinForms? A Trick by hiding Tabs.

Recently I stumbled upon a nifty trick to build a wizard control simulator (like Asp.Net wizard). Check this forum post to see how simple it is; thanks to the poster there. Taking the idea, I created a control class like this:


using System;
using System.Windows.Forms;

namespace MyProejctNameSpace
{
public class WizardControl : TabControl
{
protected override void WndProc(ref Message m)
{
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
else base.WndProc(ref m);
}
}
}

And I start using this in place of tab control and used SelectedIndex property to show each step (or tab) in the wizard simulator.
Love coding!

No comments: