Reputation: 567
iam using xtra tab, and i got 3 tab. each tab got is the same button because i put it in a panel. what i want is how do i disable the button function or event when i switch to tab 3 but still can run the function when i switch to tab 1 and tab 2.
private void simpleButton1_Click(object sender, EventArgs e)
{
add_rec()
}
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)
{
if (hi.Page.Name == "xtraTabPage1")
{
}
if (hi.Page.Name == "xtraTabPage2")
{
}
if (hi.Page.Name == "xtraTabPage3")
{
}
}
}
what code should i put in here?
iam using devexpress
without using enable or visible property at the button
Upvotes: 0
Views: 148
Reputation: 1259
Handle the XtraTabControl's SelectedPageChanging event in the following manner:
private void xtraTabControl1_SelectedPageChanging(object sender, DevExpress.XtraTab.TabPageChangingEventArgs e)
{
btnMyButton.Enabled = (e.Page == xtraTabPage1 || e.Page == xtraTabPage2);
}
Upvotes: 1
Reputation: 3979
This should do the trick:
private void simpleButton1_Click(object sender, EventArgs e)
{
if (xtraTabControl1.SelectedTabPage == tabPage1 || xtraTabControl1.SelectedTabPage == tabPage2)
{
add_rec();
}
}
Is that what you are looking for? This will check which TabPage is selected and just run the function if TabPage1 or 2 are Active.
Note that each TabPage is an own object, which is automatically created by designer if you create a XtraTabControl.
Upvotes: 1