如何根据选项卡控件显示不同的消息框。
如果我点击xtrapage1 messagebox.show("page1")
的标题页,如果我点击xtrapage2 messagebox.how("page2")
的标题页
我使用的代码是事件鼠标停止
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");
}
}
它不断显示"a"
答案 0 :(得分:1)
试试这个
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");
}
}
答案 1 :(得分:0)
试试这个
if (YourTabControl.SelectedTab.Name == "tabName" )
{
// do stuff
}
或者您可以在tab的selectedIndexChanged事件中实现相同的功能。
private void YourTabControl_SelectedIndexChanged(object sender, EventArgs e)
{
if (YourTabControl.SelectedTab == YourTabControl.TabPages["YourTabName"])
{
// your matched condition.
}
}