Skip to content

DevExpress-Examples/winforms-tabcontrol-show-checkboxes-in-page-headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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