WinForms TabControl - Display checkboxes in tab headers

This example displays checkboxes in tab page headers. The page's Tag property is used to store page state.

WinForms TabControl - Display checkboxes in tab headers

public partial class Form1 : XtraForm {
    private Dictionary<XtraTabPage, bool> _CheckedPages = new Dictionary<XtraTabPage, bool>();
    public Form1() {
        InitializeComponent();
        PaintStyleCollection.DefaultPaintStyles.Add(new MyRegistrator());
        xtraTabControl1.PaintStyleName = "MyStyle";
        xtraTabControl1.Tag = _CheckedPages;
    }
    private void xtraTabControl1_MouseDown(object sender, MouseEventArgs e) {
        DevExpress.XtraTab.ViewInfo.XtraTabHitInfo hi = xtraTabControl1.CalcHitInfo(e.Location);
        if (hi.Page == null)
            return;
        bool inCheck = ((Rectangle)hi.Page.Tag).Contains(e.Location);
        if (inCheck) {
            bool value = false;
            _CheckedPages.TryGetValue(hi.Page, out value);
            _CheckedPages[hi.Page] = !value;
        }
        xtraTabControl1.Refresh();
    }
}

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)