如何允许或禁止用户在页面控件中输入标签? [英] How to allow or forbid user to enter tab in pagecontrol?

查看:99
本文介绍了如何允许或禁止用户在页面控件中输入标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制用户(基于特殊条件)在页面控件中是否打开选项卡。即,用户可以单击选项卡,但不会显示给他。而是会显示一条消息,告诉他 他无权查看此选项卡

I want to restrict users (based on special condition) to open a tab or not in a page control. ie, the user can click on the tab but it will not be displayed to him. Instead, a message will show to him that "he don't have the access right to see such tab".

在什么情况下我应该编写检查代码,以及什么标签属性( TPageControl 组件)将允许/阻止用户输入这样的标签?

On what event I should write the checking code, and what tab property (of TPageControl component) will allow/block user to enter such tab?

推荐答案

在理想情况下,您可以将 AllowChange 设置为 False OnChanging 事件中的code>来阻止页面更改。但是,这似乎不可行,因为在用户试图选择的页面 OnChanging 中我无法发现任何方法。

In an ideal world you would set AllowChange to False from theOnChanging event to block a page change. However, this does not appear to be viable because I can find no way of discerning, from within OnChanging, which page the user is trying to select.

即使查看基本的Windows通知似乎也没有希望。 TCN_SELCHANGING 通知标识了控件,但据我所知,没有对所涉及的页面进行任何说明。

Even looking at the underlying Windows notification seems to offer little hope. The TCN_SELCHANGING notification identifies the control, but not says nothing about the pages involved, so far as I can tell.

我能想到的最好的方法是使用 OnChanging 记下当前的活动页面,然后在 OnChange

The best I can come up with is to use OnChanging to note the current active page and then do the hard work in OnChange. If the selected page has been changed to something undesirable, then just change it back.

procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean);
begin
  FPreviousPageIndex := PageControl1.ActivePageIndex;
end;

procedure TForm1.PageControl1Change(Sender: TObject);
begin
  if PageControl1.ActivePageIndex=1 then begin
    PageControl1.ActivePageIndex := FPreviousPageIndex;
    Beep;
  end;
end;

我知道有点混乱,但是它具有工作的优点!

Rather messy I know, but it has the virtue of working!

这篇关于如何允许或禁止用户在页面控件中输入标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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