chopperfield chopperfield - 2 months ago 7
C# Question

set different message base on each tab?

how can i show different message box depend on the tab control.
if i click on tab header of xtrapage1

messagebox.show("page1")
and if i click on tab header of xtrapage2
messagebox.how("page2")

the code i use was in event mouse down

private void xtraTabControl1_MouseDown(object sender, MouseEventArgs e)
{
DevExpress.XtraTab.ViewInfo.XtraTabHitInfo hi = xtraTabControl1.CalcHitInfo(e.Location);
if (hi.HitTest == DevExpress.XtraTab.ViewInfo.XtraTabHitTest.PageHeader)
{
MessageBox.Show("a");
}
}


it keeps showing
"a"


SCREEN SHOOT1

Answer

Try this

private void xtraTabControl1_MouseDown(object sender, MouseEventArgs e)
{
    DevExpress.XtraTab.ViewInfo.XtraTabHitInfo hi = xtraTabControl1.CalcHitInfo(e.Location);
    if (hi.HitTest == DevExpress.XtraTab.ViewInfo.XtraTabHitTest.PageHeader)
    {                                
        MessageBox.Show(hi.Page.Text.ToString()) );

        if(hi.Page.Name == xtraTabPage1.Text.ToString()) 
            MessageBox.Show("a");
    }
}