选项卡控件 - 阻止CTRL + Tab [英] Tab Control - Block CTRL+Tab

查看:53
本文介绍了选项卡控件 - 阻止CTRL + Tab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个向导类型程序,我正在步骤之间翻转

通过使用每个tabPage上的TabControl ..按钮移动到下一个或

previous tabPage。


但是当我按下CTRL + Tab时,tabControl开始循环通过

tabPages,就像在Visual Studio中一样, IE7等..任何标签

程序。


我需要这个被阻止。


我已经抓住了密钥来自用户的输入..当我的向导的第一个tabPage

处于活动状态时,用户按下控制键+ a,秘密

admin tabPage显示..我的老板想要这个,以便他可以动态设置向导的一些变量。
这工作非常好b / b
。所以我认为我只需要扩展它来捕获控制

+ tab键击,并且在按下它们时什么都不做..


这是我的KeyDown表单事件:


private void adminTab_KeyDown(object sender,KeyEventArgs e)

{

if(e.Modifiers。 Equals(Keys.Control)&

e.KeyCode.Equals(Keys.A)&(tcBody.SelectedTab.Equals(tabWelcomeKey)))

initAdminTab() ;


if(e.Modifiers.Equals(Keys.Control)&

e.KeyCode.Equals(Keys.Tab))

{/ *什么都不做,但是 - tabPages仍然会移动* /}

}


我有什么方法可以阻止这个控件+从我的

tabPages?基本上使用这种方法,可以从任何标签访问我的

adminTab,这是我不想要的。


我想替代方案是放置一个onTabPageChanged事件发送到我的

tabcontrol,并在那里做一些标记检查以确定我是否显示了我的管理页面。但是那只保护我的adminTab,它没有
真的阻止用户搞砸整个向导!!


任何帮助或建议?谢谢,

解决方案

2月26日下午12:26,Kbalz < Kurtas.Balc ... @ gmail.comwrote:


我正在开发一个向导类型的程序,我在步骤之间翻转

通过使用每个tabPage上的TabControl ..按钮移动到下一个或

之前的tabPage。


当我按CTRL + Tab但是,tabControl开始循环通过

tabPages,就像在Visual Studio,IE7等中一样。任何选项卡

程序。


我需要这个被阻止。


我已经抓住了用户的关键输入..当我的向导的第一个tabPage

处于活动状态时,并且用户按下控制+ a,秘密

admin tabPage显示..我的老板想要这个,以便他可以动态设置向导的一些变量。
这工作非常好b / b
。所以我认为我只需要扩展它来捕获控制

+ tab键击,并且在按下它们时什么都不做..


这是我的KeyDown表单事件:


private void adminTab_KeyDown(object sender,KeyEventArgs e)

{

if(e.Modifiers。 Equals(Keys.Control)&

e.KeyCode.Equals(Keys.A)&(tcBody.SelectedTab.Equals(tabWelcomeKey)))

initAdminTab() ;


if(e.Modifiers.Equals(Keys.Control)&

e.KeyCode.Equals(Keys.Tab))

{/ *什么都不做,但是 - tabPages仍然会移动* /}

}


我有什么方法可以阻止这个控件+从我的

tabPages?基本上使用这种方法,可以从任何标签访问我的

adminTab,这是我不想要的。


我想替代方案是放置一个onTabPageChanged事件发送到我的

tabcontrol,并在那里做一些标记检查以确定我是否显示了我的管理页面。但是那只能保护我的adminTab,它并没有实际上阻止用户搞砸整个向导!



我知道这在游戏后期听起来很糟糕,但是......任何

你使用TabControl的特殊原因你的巫师?所有的向导我已经完成了我使用UserControls(基本上是面板的b $ b $),显示并隐藏了程序下的用户控件

控制。他们都是.Dock = Dock.Fill,我只是在适当的时候在它们之间洗牌。


我认为TabControl也附带了额外的问题

用户可以随时点击任何标签并搞砸向导

那样顺序....


无论如何,现在它已经差不多完成了...... :-)


2月26日,3:下午56点,布鲁斯伍德 < brucew ... @ canada.comwrote:


2月26日下午12:26,Kbalz < Kurtas.Balc ... @ gmail.comwrote:



我正在开发一个向导类型程序,我'通过使用每个tabPage上的TabControl ..按钮移动到下一个或

之前的tabPage,在步骤之间翻转



当我按下CTRL + Tab时,tabControl开始循环通过

tabPages,就像它在Visual Studio,IE7等..任何选项卡

程序。


我需要阻止它。


我已经捕获了用户的关键输入..当我的向导的第一个tabPage

处于活动状态时,用户按下控制键+ a,秘密

admin tabPage显示..我的老板想要这个,以便他可以动态设置向导的一些变量。
这工作非常好b / b
。所以我认为我只需要扩展它来捕获控制

+ tab键击,并且在按下它们时什么都不做..


这是我的Form的KeyDown事件:


private void adminTab_KeyDown(object sender,KeyEventArgs e)

{

if(e.Modifiers.Equals(Keys.Control)&

e.KeyCode.Equals(Keys.A)&(tcBody.SelectedTab.Equals (tabWelcomeKey)))

initAdminTab();


if(e.Modifiers.Equals(Keys.Control)&

e.KeyCode.Equals(Keys。 Tab))

{/ *什么都不做,但是 - tabPages仍然移动* /}

}


有什么办法可以阻止这个控件+标签来翻动我的

tabPages吗?基本上使用这种方法,可以从任何标签访问我的

adminTab,这是我不想要的。


我想另一种方法是放置一个onTabPageChanged。事件发送到我的

tabcontrol,并在那里做一些标记检查以确定我是否显示了我的管理页面。但是那只能保护我的adminTab,它并没有实际上阻止用户搞砸整个向导!



我知道这在游戏后期听起来很糟糕,但是......任何

你使用TabControl的特殊原因你的巫师?所有的向导我已经完成了我使用UserControls(基本上是面板的b $ b $),显示并隐藏了程序下的用户控件

控制。他们都是.Dock = Dock.Fill,我只是在适当的时候在它们之间洗牌。


我认为TabControl也附带了额外的问题

用户可以随时点击任何标签并搞砸向导

那样顺序....


无论如何,现在它几乎已经完成了......: - ) - 隐藏引用的文字 -


- 显示引用的文字 -



相信我,如果我原本知道一种更简单的方式 - 我会做的那样。

。我正在做的是当表单出现时,我正在调整

tabcontrol的大小,并使用负值定位它,所以

表示;凸片"隐藏,无法点击。因此,虽然我是设计步骤的内容,但我可以通过单击选项卡轻松地在步骤之间切换,但在运行时,选项卡将被隐藏。 br />

我从Google的C#Form向导那里得到了这个想法,并且看到一个网站

给一个使用tabcontrols开发向导的人 - 所以我拿了

来自那里的想法并继续使用它。


如果UserControl可以给我相同的设计时间/运行时间

的能力,我没有问题切换它(这是我唯一的项目

atm)。我们已经向这个向导添加了另一层,这导致我

在tabPages中有tabControls !!现在它变得越来越混乱。




" Kbalz" < Ku ************ @ gmail.com写信息

新闻:11 ****************** ***@z35g2000cwz.googlegro ups.com ...


我正在开发一个向导类型程序,我在步骤之间翻转

通过使用每个tabPage上的TabControl ..按钮移动到下一个或

之前的tabPage。


当我按CTRL + Tab但是,tabControl开始循环通过

tabPages,就像在Visual Studio,IE7等中一样。任何选项卡

程序。


我需要这个被阻止。


我已经抓住了用户的关键输入..当我的向导的第一个tabPage

处于活动状态时,并且用户按下控制+ a,秘密

admin tabPage显示..我的老板想要这个,以便他可以动态设置向导的一些变量。
这工作非常好b / b
。所以我认为我只需要扩展它来捕获控制

+ tab键击,并且在按下它们时什么都不做..


这是我的KeyDown表单事件:


private void adminTab_KeyDown(object sender,KeyEventArgs e)

{

if(e.Modifiers。 Equals(Keys.Control)&

e.KeyCode.Equals(Keys.A)&(tcBody.SelectedTab.Equals(tabWelcomeKey)))

initAdminTab() ;


if(e.Modifiers.Equals(Keys.Control)&

e.KeyCode.Equals(Keys.Tab))

{/ *什么都不做,但是 - tabPages仍然会移动* /}

}


我有什么方法可以阻止这个控件+从我的

tabPages?基本上使用这种方法,可以从任何标签访问我的

adminTab,这是我不想要的。



你有没有看到这个?


要仅在表单级别处理键盘事件而不启用其他

控件来接收键盘事件,请设置KeyPressEventArgs.Handled

属性在你的表单'的KeyPress事件处理方法为true。某些

键,例如TAB,RETURN,ESCAPE和箭头键,由

控件自动处理。要让这些键引发KeyDown事件,您必须

覆盖表单上每个控件中的IsInputKey方法。

的代码IsInputKey的覆盖需要确定是否按下了一个特殊的

键并返回值true。


I''m developing a Wizard type program, and I''m flipping between steps
by using a TabControl.. buttons on each tabPage move to the next or
previous tabPage.

When I press CTRL+Tab however, the tabControl begins to cycle through
the tabPages, just as it does in Visual Studio, IE7 etc.. any tabbed
program.

I need this blocked.

I am already catching key input from the user.. when the first tabPage
of my Wizard is active, and the user presses control+a, a "secret
admin" tabPage is shown.. My boss wanted this so that he could
dynamically set some variables for the wizard. This is working very
well. So I thought I only needed to extend this to capture control
+tab key strokes, and do nothing when they are pressed..

Here is my KeyDown event for the Form:

private void adminTab_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.A) & (tcBody.SelectedTab.Equals(tabWelcomeKey)))
initAdminTab();

if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.Tab))
{ /* do nothing, however - the tabPages still move */ }
}

Is there any way I can block this control+tab from fliping my
tabPages? Basically using this method, it is possible to access my
adminTab from any tab, which I don''t want.

I guess the alternative is to place a "onTabPageChanged" event to my
tabcontrol, and do some flag checking there to determine if I display
my admin page or not. But that only protect my adminTab, it doesn''t
really prevent the user from screwing up the entire wizard !!

Any help or suggestions ? Thanks,

解决方案

On Feb 26, 12:26 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:

I''m developing a Wizard type program, and I''m flipping between steps
by using a TabControl.. buttons on each tabPage move to the next or
previous tabPage.

When I press CTRL+Tab however, the tabControl begins to cycle through
the tabPages, just as it does in Visual Studio, IE7 etc.. any tabbed
program.

I need this blocked.

I am already catching key input from the user.. when the first tabPage
of my Wizard is active, and the user presses control+a, a "secret
admin" tabPage is shown.. My boss wanted this so that he could
dynamically set some variables for the wizard. This is working very
well. So I thought I only needed to extend this to capture control
+tab key strokes, and do nothing when they are pressed..

Here is my KeyDown event for the Form:

private void adminTab_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.A) & (tcBody.SelectedTab.Equals(tabWelcomeKey)))
initAdminTab();

if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.Tab))
{ /* do nothing, however - the tabPages still move */ }
}

Is there any way I can block this control+tab from fliping my
tabPages? Basically using this method, it is possible to access my
adminTab from any tab, which I don''t want.

I guess the alternative is to place a "onTabPageChanged" event to my
tabcontrol, and do some flag checking there to determine if I display
my admin page or not. But that only protect my adminTab, it doesn''t
really prevent the user from screwing up the entire wizard !!

I know that this sounds awful this late in the game, but... any
particular reason you''re using a TabControl for your wizard? All of
the wizards I''ve done I''ve made using UserControls (which are
basically Panels), showing and hiding the user controls under program
control. They''re all .Dock = Dock.Fill, and I just shuffle between
them as appropriate.

I would think that TabControl also comes with the additional problem
that the user can click on any tab, any time and screw up the wizard
sequence that way....

Anyway, kind of a bummer question now that it''s almost done.... :-)


On Feb 26, 3:56 pm, "Bruce Wood" <brucew...@canada.comwrote:

On Feb 26, 12:26 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:


I''m developing a Wizard type program, and I''m flipping between steps
by using a TabControl.. buttons on each tabPage move to the next or
previous tabPage.

When I press CTRL+Tab however, the tabControl begins to cycle through
the tabPages, just as it does in Visual Studio, IE7 etc.. any tabbed
program.

I need this blocked.

I am already catching key input from the user.. when the first tabPage
of my Wizard is active, and the user presses control+a, a "secret
admin" tabPage is shown.. My boss wanted this so that he could
dynamically set some variables for the wizard. This is working very
well. So I thought I only needed to extend this to capture control
+tab key strokes, and do nothing when they are pressed..

Here is my KeyDown event for the Form:

private void adminTab_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.A) & (tcBody.SelectedTab.Equals(tabWelcomeKey)))
initAdminTab();

if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.Tab))
{ /* do nothing, however - the tabPages still move */ }
}

Is there any way I can block this control+tab from fliping my
tabPages? Basically using this method, it is possible to access my
adminTab from any tab, which I don''t want.

I guess the alternative is to place a "onTabPageChanged" event to my
tabcontrol, and do some flag checking there to determine if I display
my admin page or not. But that only protect my adminTab, it doesn''t
really prevent the user from screwing up the entire wizard !!


I know that this sounds awful this late in the game, but... any
particular reason you''re using a TabControl for your wizard? All of
the wizards I''ve done I''ve made using UserControls (which are
basically Panels), showing and hiding the user controls under program
control. They''re all .Dock = Dock.Fill, and I just shuffle between
them as appropriate.

I would think that TabControl also comes with the additional problem
that the user can click on any tab, any time and screw up the wizard
sequence that way....

Anyway, kind of a bummer question now that it''s almost done.... :-)- Hide quoted text -

- Show quoted text -

Belive me, if I originally knew of an easier way - I would''ve done
that. What I''m doing is when the form inits, I''m resizing the
tabcontrol to be larger, and position it using negative values, so
that the "tabs" are hidden and cannot be clicked. So while I''m
designing the content of the steps, I can easly switch between steps
by clicking the tabs, but at runtime, the tabs become hidden.

I got the idea from Google''ing C# Form wizards, and saw some website
for a guy who developed a wizard using tabcontrols - so I took the
idea from there and went on my way with it.

If the UserControl can give me the same design-time/run-time
capability, I have no problem switching it (this is my only project
atm). We''ve added another layer to this Wizard that is causing me to
have tabControls within tabPages !! Now it''s getting messy fast.



"Kbalz" <Ku************@gmail.comwrote in message
news:11*********************@z35g2000cwz.googlegro ups.com...

I''m developing a Wizard type program, and I''m flipping between steps
by using a TabControl.. buttons on each tabPage move to the next or
previous tabPage.

When I press CTRL+Tab however, the tabControl begins to cycle through
the tabPages, just as it does in Visual Studio, IE7 etc.. any tabbed
program.

I need this blocked.

I am already catching key input from the user.. when the first tabPage
of my Wizard is active, and the user presses control+a, a "secret
admin" tabPage is shown.. My boss wanted this so that he could
dynamically set some variables for the wizard. This is working very
well. So I thought I only needed to extend this to capture control
+tab key strokes, and do nothing when they are pressed..

Here is my KeyDown event for the Form:

private void adminTab_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.A) & (tcBody.SelectedTab.Equals(tabWelcomeKey)))
initAdminTab();

if (e.Modifiers.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.Tab))
{ /* do nothing, however - the tabPages still move */ }
}

Is there any way I can block this control+tab from fliping my
tabPages? Basically using this method, it is possible to access my
adminTab from any tab, which I don''t want.

Did you see this?

To handle keyboard events only at the form level and not enable other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form''s KeyPress event-handling method to true. Certain
keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled by
controls automatically. To have these keys raise the KeyDown event, you must
override the IsInputKey method in each control on your form. The code for
the override of the IsInputKey would need to determine if one of the special
keys is pressed and return a value of true.


这篇关于选项卡控件 - 阻止CTRL + Tab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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