认证后显示标签页 [英] Showing TabPages After Authentication

查看:78
本文介绍了认证后显示标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...这是一个REPOST.在我的程序中,用户首先需要在 Tab1 上输入凭据,以便能够查看其余选项卡(及其上的控件).如果提供了错误的凭据,则在单击任何其他选项卡时,一秒钟的时间会显示另一个选项卡(我在其中单击:说 Tab3 ),然后几乎立即切换回第一个标签页,尽管代码可以正常运行.到目前为止,这是我尝试过的

hello guys... Its a REPOST. In my program, user will first need to enter the credentials on Tab1, in order to be able to see the rest of the tabs (and controls on it). If wrong credentials are given then upon clicking any other tab, for a fraction of second it shows the other tab (onwhich I click: say Tab3) then switches almost immediately back to first tab, although the code works fine . Here is what I have tried so far

private void OnMouseDown(object sender, MouseEventArgs e) 
{
  if (e.Button == MouseButtons.Left)
  {
      if (tabMainTabCtrl.SelectedIndex != 0)
      {
        if (IsUserAuthenticated) // this is set when user is authenticated or not
          tabMainTabCtrl.SelectedIndex = m_iSelectedTab;
        else
          tabMainTabCtrl.SelectedIndex = 0;
      }
  }
}

private void tabMainTabCtrl_SelectedIndexChanged(object sender, EventArgs e)
{
     m_iSelectedTab = tabMainTabCtrl.SelectedIndex; //m_iSelectedTab: class level global variable
}


如我所说,它工作正常,但似乎很奇怪.那么,什么是更好的解决方案呢? thnx输入任何内容.


As I said, it works fine but it seems strange. So what can be a better solution? thnx for any input.

推荐答案

Hello Overloaded_Name,

删除OnMouseDown方法并按如下所示更改tabMainTabCtrl_SelectedIndexChanged方法

Hello Overloaded_Name,

Delete the OnMouseDown method and change tabMainTabCtrl_SelectedIndexChanged method as below

private void tabMainTabCtrl_SelectedIndexChanged(object sender, EventArgs e)
{
     if ( tabMainTabCtrl.SelectedIndex != 0)
     {
       if ( !IsUserAuthenticated )
       {
         MessageBox.Show("You are not authenticated user");
         tabMainTabCtrl.SelectedIndex = 0;
       }
     }
}



我想这对您有帮助.



I thing this help you.


这篇关于认证后显示标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆