Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

net tab stopping user seeing contents

Hi

Have windows application c#

Tab - I want on click event of tab - to show warning message if no permission

But in method tab selected it is too late as after messagebox it still goes to tab contents - where do I put code please
Rgds
Stephen
0
stephenwilde
Asked:
stephenwilde
  • 2
  • 2
1 Solution
 
elimesikaCommented:
HI

You should use the Selecting Event that has TabControlCancelEventArgs  
0
 
stephenwildeAuthor Commented:
Hi

Thanks for your reply - but could you expain your soution a little bit more please and I cannot find a cancel event

Rgds
stephen
0
 
elimesikaCommented:
HI Stephen

You have to implement the Selecting event and use the passed argument to cancel the switching

Something like this ....
private void tabControl_Selecting(object sender,TabControlCancelEventArgs e)
{
 
e.Cancel = !IsAuthorized();
 
}
 
private bool IsAuthorized () {
 
// check authorization and return true/false
}

Open in new window

0
 
stephenwildeAuthor Commented:
Thank you
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now