我们可以覆盖控制的tabstop属性吗? [英] Can we override tabstop property of control?

查看:89
本文介绍了我们可以覆盖控制的tabstop属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从控件派生的usercontrol,我可以覆盖TabStop属性进行一些修改。?

如果是这样,请告诉我,如何覆盖我的usercontrol中的tabstop属性。



我尝试了什么:



i试图覆盖tabstop在我的usercontrol中,但tabstop属性未在覆盖属性中列出

I have a usercontrol which is derived from control, can i override the TabStop property to have some modification.?
If so please let me know, how to override the tabstop property in my usercontrol.

What I have tried:

i have tried to override the tabstop in my usercontrol, but the tabstop property is not listed in override properties

推荐答案

Tabstop只是一个bool,告诉系统用户输入焦点可以转到当他按下TAB键时控制:如果是,则控件包含在TabIndex属性指示的位置的tabable控件集合中。覆盖它(由于它未标记为虚拟,抽象或覆盖而无法执行)将不允许您向选项卡进程添加实际功能。您可以隐藏原始实现:

Tabstop is just a bool, which tells the system that the user input focus can go to the control when he presses the TAB key: if it's true, the control is included in the "tabable" controls collection at the position indicated by the TabIndex property. Overriding it (which you can't do as it's not marked virtual, abstract, or override) wouldn't allow you to add and real functionality to the tab process. You can hide teh original implementation:
public new  bool TabStop { get; set; }

这可能会阻止TAB键被用来输入它,但这就是所有。

如果你想修改TAB行为(和我真的不推荐它)你可能需要在父容器中覆盖 WndProc ProcessCmdKey 并自己过滤掉TAB。



忽略WndProc,你需要ProcessCommandKey(我的咖啡因没有上次完全开始):

Which would probably prevent the TAB key from ever being used to enter it, but that's about all.
If you want to modify TAB behaviour (and I really don't recommend it) you probably need to override WndProc ProcessCmdKey in the parent container and filter out TAB yourself.

Ignore WndProc, you need ProcessCommandKey (my caffeine hadn;t kicked in fully last time):

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
    Keys keyPressed = (Keys)(int)msg.WParam;
    if (keyData == Keys.Tab)
        {
        Console.WriteLine("Tab!");
        return true;
        }
    return base.ProcessCmdKey(ref msg, keyData);
    }

但严重的是:FAB具有TAB功能需要您自担风险!用户习惯于做特定的事情,你真的不想破坏它,或者他们会以你不相信的激情恨你的应用......

But seriously: Faff with TAB functionality at your own risk! Users are used to it doing particular things, and you really don't want to subvert that or they will hate your app with a passion you will not believe...


这篇关于我们可以覆盖控制的tabstop属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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