473,379 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Tab Control - Block CTRL+Tab

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,

Feb 26 '07 #1
17 7338
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.... :-)

Feb 26 '07 #2
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.

Feb 26 '07 #3

"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.
Feb 26 '07 #4
On Feb 26, 1:08 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
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.
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.... :-)

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.
Yikes. Glad I didn't find that one when I was doing my initial foray
into wizards....
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.
Personally, I'd switch.

Create a UserControl for each panel you want to show. You should be
able to just cut all of the stuff off of your current tab and past it
onto the UserControl surface. Your Wizard then becomes an empty shell
into which you drop all of the UserControls (Dock = None). No need to
see them all clearly: just be able to see that they're all there.

Then, at run time, just set all UserControls to Dock = Fill, and
Hide() all of them but the initial panel.

I even created a little push-down stack in the main Wizard app that
stores references to the UserControls already visited, so when the
user presses Back I can pop the top one off the stack and show the
next one down on the stack. This allows you to deal gracefully handle
"conversations" that branch off into various possibilities and then
reconverge.

I also created an interface / interfaces so that the individual
controls can be marked with capabilities that tell the enclosing
Wizard what services they can offer (e.g. "should I offer a Print...
menu item when this panel is showing?").

This gives you a separate design surface for each "page" you want to
show the user (each is a UserControl) and reduces your Wizard
application .cs itself to just the plumbing needed to link them
together, and your ctl-a trick, of course.

Feb 26 '07 #5
On Feb 26, 5:08 pm, "Bruce Wood" <brucew...@canada.comwrote:
On Feb 26, 1:08 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:


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.
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.... :-)
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.

Yikes. Glad I didn't find that one when I was doing my initial foray
into wizards....
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.

Personally, I'd switch.

Create a UserControl for each panel you want to show. You should be
able to just cut all of the stuff off of your current tab and past it
onto the UserControl surface. Your Wizard then becomes an empty shell
into which you drop all of the UserControls (Dock = None). No need to
see them all clearly: just be able to see that they're all there.

Then, at run time, just set all UserControls to Dock = Fill, and
Hide() all of them but the initial panel.

I even created a little push-down stack in the main Wizard app that
stores references to the UserControls already visited, so when the
user presses Back I can pop the top one off the stack and show the
next one down on the stack. This allows you to deal gracefully handle
"conversations" that branch off into various possibilities and then
reconverge.

I also created an interface / interfaces so that the individual
controls can be marked with capabilities that tell the enclosing
Wizard what services they can offer (e.g. "should I offer a Print...
menu item when this panel is showing?").

This gives you a separate design surface for each "page" you want to
show the user (each is a UserControl) and reduces your Wizard
application .cs itself to just the plumbing needed to link them
together, and your ctl-a trick, of course.- Hide quoted text -

- Show quoted text -
Thanks for the reply. I can kind of visualize how that approach works
during design time, but I could possibly be having 20 possible "pages"
to show the user. Wouldn't the design-time view in VS'05 get very
cluttered and hard to quickly find which page is which? In the first
take at my wizard, I had started close to how you described it. I
didn't know about the Dock = Fill property however until a few weeks
ago after I switched it all to tabcontrol. Instead I was setting all
of the Position properties to a set Point, and making them all the
same Size - this worked with an un-sizable Form pertty well until I
got too many pages.

I've protected my ctrl+a page by using flags, so I'm safe there. Maybe
if you could email me a screen shot of a design-time example of a ton
of UserControls for one of your wizards, this will make my switch a
little easier with something to go by. Thanks,

Feb 27 '07 #6
On Feb 27, 8:54 am, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
On Feb 26, 5:08 pm, "Bruce Wood" <brucew...@canada.comwrote:


On Feb 26, 1:08 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
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.
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.... :-)
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.
Yikes. Glad I didn't find that one when I was doing my initial foray
into wizards....
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.
Personally, I'd switch.
Create a UserControl for each panel you want to show. You should be
able to just cut all of the stuff off of your current tab and past it
onto the UserControl surface. Your Wizard then becomes an empty shell
into which you drop all of the UserControls (Dock = None). No need to
see them all clearly: just be able to see that they're all there.
Then, at run time, just set all UserControls to Dock = Fill, and
Hide() all of them but the initial panel.
I even created a little push-down stack in the main Wizard app that
stores references to the UserControls already visited, so when the
user presses Back I can pop the top one off the stack and show the
next one down on the stack. This allows you to deal gracefully handle
"conversations" that branch off into various possibilities and then
reconverge.
I also created an interface / interfaces so that the individual
controls can be marked with capabilities that tell the enclosing
Wizard what services they can offer (e.g. "should I offer a Print...
menu item when this panel is showing?").
This gives you a separate design surface for each "page" you want to
show the user (each is a UserControl) and reduces your Wizard
application .cs itself to just the plumbing needed to link them
together, and your ctl-a trick, of course.- Hide quoted text -
- Show quoted text -

Thanks for the reply. I can kind of visualize how that approach works
during design time, but I could possibly be having 20 possible "pages"
to show the user. Wouldn't the design-time view in VS'05 get very
cluttered and hard to quickly find which page is which? In the first
take at my wizard, I had started close to how you described it. I
didn't know about the Dock = Fill property however until a few weeks
ago after I switched it all to tabcontrol. Instead I was setting all
of the Position properties to a set Point, and making them all the
same Size - this worked with an un-sizable Form pertty well until I
got too many pages.

I've protected my ctrl+a page by using flags, so I'm safe there. Maybe
if you could email me a screen shot of a design-time example of a ton
of UserControls for one of your wizards, this will make my switch a
little easier with something to go by. Thanks,- Hide quoted text -

- Show quoted text -
I started to jump into a fresh wizard using UserControl.. until an
hour ago, I thought this was something I could just find in the
toolbox and drag and drop in my existing form!! I now see I must add a
new UserControl.cs to my project.. and I'm guessing I would add a
UserControl for each step in my wizard, then somehow get them to all
show in my form.

I'll keep trying a few things, but this is already looking 100% easier.

Feb 27 '07 #7
>Thanks for the reply. I can kind of visualize how that approach works
>during design time, but I could possibly be having 20 possible "pages"
to show the user. Wouldn't the design-time view in VS'05 get very
cluttered and hard to quickly find which page is which? In the first
take at my wizard, I had started close to how you described it. I
didn't know about the Dock = Fill property however until a few weeks
ago after I switched it all to tabcontrol. Instead I was setting all
of the Position properties to a set Point, and making them all the
same Size - this worked with an un-sizable Form pertty well until I
got too many pages.

I've protected my ctrl+a page by using flags, so I'm safe there. Maybe
if you could email me a screen shot of a design-time example of a ton
of UserControls for one of your wizards, this will make my switch a
little easier with something to go by. Thanks,- Hide quoted text -

- Show quoted text -

I started to jump into a fresh wizard using UserControl.. until an
hour ago, I thought this was something I could just find in the
toolbox and drag and drop in my existing form!! I now see I must add a
new UserControl.cs to my project.. and I'm guessing I would add a
UserControl for each step in my wizard, then somehow get them to all
show in my form.
You could do that too.... with the predefined Panel control. But then you'd
need to mess with raising and lowering the different panels in the designer.
>
I'll keep trying a few things, but this is already looking 100% easier.

Feb 27 '07 #8
On Feb 27, 11:11 am, "Ben Voigt" <r...@nospam.nospamwrote:
Thanks for the reply. I can kind of visualize how that approach works
during design time, but I could possibly be having 20 possible "pages"
to show the user. Wouldn't the design-time view in VS'05 get very
cluttered and hard to quickly find which page is which? In the first
take at my wizard, I had started close to how you described it. I
didn't know about the Dock = Fill property however until a few weeks
ago after I switched it all to tabcontrol. Instead I was setting all
of the Position properties to a set Point, and making them all the
same Size - this worked with an un-sizable Form pertty well until I
got too many pages.
I've protected my ctrl+a page by using flags, so I'm safe there. Maybe
if you could email me a screen shot of a design-time example of a ton
of UserControls for one of your wizards, this will make my switch a
little easier with something to go by. Thanks,- Hide quoted text -
- Show quoted text -
I started to jump into a fresh wizard using UserControl.. until an
hour ago, I thought this was something I could just find in the
toolbox and drag and drop in my existing form!! I now see I must add a
new UserControl.cs to my project.. and I'm guessing I would add a
UserControl for each step in my wizard, then somehow get them to all
show in my form.

You could do that too.... with the predefined Panel control. But then you'd
need to mess with raising and lowering the different panels in the designer.


I'll keep trying a few things, but this is already looking 100% easier.- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Thats what I was doing with my first take on the wizard, I didn't care
for it that much, but again I didn't know about dock = fill ! I'm
still having trouble getting a UserControl I make into a Form - just
got back from lunch and going to read a few things.

Feb 27 '07 #9
On Feb 27, 12:45 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
On Feb 27, 11:11 am, "Ben Voigt" <r...@nospam.nospamwrote:


>Thanks for the reply. I can kind of visualize how that approach works
>during design time, but I could possibly be having 20 possible "pages"
>to show the user. Wouldn't the design-time view in VS'05 get very
>cluttered and hard to quickly find which page is which? In the first
>take at my wizard, I had started close to how you described it. I
>didn't know about the Dock = Fill property however until a few weeks
>ago after I switched it all to tabcontrol. Instead I was setting all
>of the Position properties to a set Point, and making them all the
>same Size - this worked with an un-sizable Form pertty well until I
>got too many pages.
>I've protected my ctrl+a page by using flags, so I'm safe there. Maybe
>if you could email me a screen shot of a design-time example of a ton
>of UserControls for one of your wizards, this will make my switch a
>little easier with something to go by. Thanks,- Hide quoted text -
>- Show quoted text -
I started to jump into a fresh wizard using UserControl.. until an
hour ago, I thought this was something I could just find in the
toolbox and drag and drop in my existing form!! I now see I must add a
new UserControl.cs to my project.. and I'm guessing I would add a
UserControl for each step in my wizard, then somehow get them to all
show in my form.
You could do that too.... with the predefined Panel control. But then you'd
need to mess with raising and lowering the different panels in the designer.
I'll keep trying a few things, but this is already looking 100% easier.- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

Thats what I was doing with my first take on the wizard, I didn't care
for it that much, but again I didn't know about dock = fill ! I'm
still having trouble getting a UserControl I make into a Form - just
got back from lunch and going to read a few things.- Hide quoted text -

- Show quoted text -
Wow this is much easier to manage using UserControls.. its kind of sad
I couldn't find any great articles on this method earlier!! This
solves my Tab problem, and probably many problems I was bound to come
accross before. Thanks a ton !

Feb 27 '07 #10
On Feb 27, 8:01 am, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
I started to jump into a fresh wizard using UserControl.. until an
hour ago, I thought this was something I could just find in the
toolbox and drag and drop in my existing form!! I now see I must add a
new UserControl.cs to my project.. and I'm guessing I would add a
UserControl for each step in my wizard, then somehow get them to all
show in my form.
Yes, that's right. You design each "panel" (UserControl) as a separate
control in your project. Then you just drag them all onto your
"wizard" container and manipulate them in code. Since you always edit
an individual panel in a separate Designer window (as a UserControl),
you don't really care that the "wizard" container looks cluttered...
you just have to see that they're all there.

Feb 27 '07 #11
On Feb 27, 9:45 am, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
<snip>
Thats what I was doing with my first take on the wizard, I didn't care
for it that much, but again I didn't know about dock = fill ! I'm
still having trouble getting a UserControl I make into a Form - just
got back from lunch and going to read a few things.
Make a separate Form... that's your Wizard, and then drop the
UserControls onto it. They don't need to look pretty... make 'em
small, and stack 'em up. It doesn't matter. You just need to be able
to see that they're all there.

Once you have that, your Form then acts as the coordinator, showing
and hiding the UserControls as necessary, and reacting to button
presses and/or events from each UserControl to decide what to do next.

The UserControls themselves should be ignorant of their container:
just expose properties to get results / set inputs, and publish events
to say what happened.

For example, I have the Next and Back buttons on my individual
UserControls, so my UserControls expose an event called Done and a
property called DoneAction. When the user presses Next I set
DoneAction to DoneAction.Next and raise the Done event, which is then
picked up by the enclosing Form (wizard) which decides which
UserControl to show as a result.

You could just as easily put the buttons on the enclosing Form and
have each UserControl expose a NextValid bool property and
NextValidChanged event to advise the Form when it should enable /
disable the Next button. Same effect, different solution.

Basically, the individual UserControls are concerned with collecting
information, while the Form is concerned with coordination, which
includes passing information from one UserControl to the next.

Feb 27 '07 #12
On Feb 27, 2:28 pm, "Bruce Wood" <brucew...@canada.comwrote:
On Feb 27, 9:45 am, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
<snip>
Thats what I was doing with my first take on the wizard, I didn't care
for it that much, but again I didn't know about dock = fill ! I'm
still having trouble getting a UserControl I make into a Form - just
got back from lunch and going to read a few things.

Make a separate Form... that's your Wizard, and then drop the
UserControls onto it. They don't need to look pretty... make 'em
small, and stack 'em up. It doesn't matter. You just need to be able
to see that they're all there.

Once you have that, your Form then acts as the coordinator, showing
and hiding the UserControls as necessary, and reacting to button
presses and/or events from each UserControl to decide what to do next.

The UserControls themselves should be ignorant of their container:
just expose properties to get results / set inputs, and publish events
to say what happened.

For example, I have the Next and Back buttons on my individual
UserControls, so my UserControls expose an event called Done and a
property called DoneAction. When the user presses Next I set
DoneAction to DoneAction.Next and raise the Done event, which is then
picked up by the enclosing Form (wizard) which decides which
UserControl to show as a result.

You could just as easily put the buttons on the enclosing Form and
have each UserControl expose a NextValid bool property and
NextValidChanged event to advise the Form when it should enable /
disable the Next button. Same effect, different solution.

Basically, the individual UserControls are concerned with collecting
information, while the Form is concerned with coordination, which
includes passing information from one UserControl to the next.
Thanks for all of those tips, they make sense and I'm moving the
tabPages into new UserControls very quickly - luckly when I did my
TabControl, it was already unaware of how the next/back buttons moved
the tabPages from one to the next.. so plugging the UserControl in the
tabcontrol's place is really easy - and I gain all of the flexibility
you've mentioned.

One thing it seems I have to do a little extra work is for passing
information from a UserControl's Textbox to the Form. To access this,
do I need to write a method to return the text property inside of the
user control, and call this from the Form? It would be nice if I could
go UserControl1.TextBox1.Text instead of
UserControl1.getTextBox1Text() or is there a way I'm not seeing?
I'm only collecting a dozen or so fields from the user so its not a
big deal, but for my own knowledge I'd like to know if there is a
different way you suggest.

Also I'm trying to setup a UserControl as a template, so when I want
to create a new step in my wizard, I select it and it already has Size
setup so I know how much area I have to fit controls in, and margins
to 0 etc.. I've searched for a bit trying to see, but all examples are
in ASP.NET - is this possible as well?

Thanks again for you help!

Feb 27 '07 #13
On Feb 27, 12:56 pm, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
On Feb 27, 2:28 pm, "Bruce Wood" <brucew...@canada.comwrote:
On Feb 27, 9:45 am, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
<snip>
Thats what I was doing with my first take on the wizard, I didn't care
for it that much, but again I didn't know about dock = fill ! I'm
still having trouble getting a UserControl I make into a Form - just
got back from lunch and going to read a few things.
Make a separate Form... that's your Wizard, and then drop the
UserControls onto it. They don't need to look pretty... make 'em
small, and stack 'em up. It doesn't matter. You just need to be able
to see that they're all there.
Once you have that, your Form then acts as the coordinator, showing
and hiding the UserControls as necessary, and reacting to button
presses and/or events from each UserControl to decide what to do next.
The UserControls themselves should be ignorant of their container:
just expose properties to get results / set inputs, and publish events
to say what happened.
For example, I have the Next and Back buttons on my individual
UserControls, so my UserControls expose an event called Done and a
property called DoneAction. When the user presses Next I set
DoneAction to DoneAction.Next and raise the Done event, which is then
picked up by the enclosing Form (wizard) which decides which
UserControl to show as a result.
You could just as easily put the buttons on the enclosing Form and
have each UserControl expose a NextValid bool property and
NextValidChanged event to advise the Form when it should enable /
disable the Next button. Same effect, different solution.
Basically, the individual UserControls are concerned with collecting
information, while the Form is concerned with coordination, which
includes passing information from one UserControl to the next.

Thanks for all of those tips, they make sense and I'm moving the
tabPages into new UserControls very quickly - luckly when I did my
TabControl, it was already unaware of how the next/back buttons moved
the tabPages from one to the next.. so plugging the UserControl in the
tabcontrol's place is really easy - and I gain all of the flexibility
you've mentioned.

One thing it seems I have to do a little extra work is for passing
information from a UserControl's Textbox to the Form. To access this,
do I need to write a method to return the text property inside of the
user control, and call this from the Form? It would be nice if I could
go UserControl1.TextBox1.Text instead of
UserControl1.getTextBox1Text() or is there a way I'm not seeing?
I'm only collecting a dozen or so fields from the user so its not a
big deal, but for my own knowledge I'd like to know if there is a
different way you suggest.
Well, this is a matter of taste... bad taste and my taste. ;-)

IMHO the ugly way to do it is to expose the controls as public and
just grab information straight from them. It's ugly because if you
ever change your wizard panel to show the information differently
(e.g. change a text box to a combo box one day) then you break your
wizard.

I prefer to create a property for each piece of information I need to
retrieve from / send to a UserControl, and name that property after
the information, not after the way it's displayed. So I have
properties called CustomerName, ImageFilePath, ChosenStockItems, etc.
If they're coming back from the UserControl into the wizard, then
they're get-only. If they're being set from the wizard into the
UserControl then they're get/set. It's a bit of extra plumbing, but it
makes the wizard controller form much more readable, e.g.:

this.userControl2.CustomerName = this.userControl1.CustomerName;
this.userControl1.Hide();
this.userControl2.Show();

tells me right away that the second panel needs the customer name
which was set in the first panel.

As I mentioned earlier, I also have public events in my UserControls
via which they notify the wizard that something interesting has
happened, such as the user pressing "Next", "Back", or "Cancel". I
could have simply exposed the UserControl's buttons as public and had
the wizard subscribe to their events directly, but IMHO that's just
nasty.

I prefer that my UserControls are "black boxes": they require certain
inputs, ask the user for information which they return as properties,
and raise events when the user does something noteworthy. Everything
else is hidden inside. It's more code this way, but I think that it's
easier to understand in the long run.
Also I'm trying to setup a UserControl as a template, so when I want
to create a new step in my wizard, I select it and it already has Size
setup so I know how much area I have to fit controls in, and margins
to 0 etc.. I've searched for a bit trying to see, but all examples are
in ASP.NET - is this possible as well?
You should be able to create a UserControl class and set it up the way
you want. Then you can inherit from it. The "cheesy" way to do this is
to simply create a new UserControl, then hand-modify the code to say:

public class MyUserControl1 : MyUserControlTemplate

instead of what the Designer produces, which is:

public class MyUserControl1 : UserControl

I'm sure that there's some fancy way to do this in the Designer, but
it's so quick and easy to just tweak it that I've never bothered
figuring out how to do it "visually".

Feb 28 '07 #14
On Feb 27, 8:36 pm, "Bruce Wood" <brucew...@canada.comwrote:

Your inherite way is the best since if you ever change the template
you are inheriting from, then all of your UC's will inherit those
changes.
I'm sure that there's some fancy way to do this in the Designer, but
it's so quick and easy to just tweak it that I've never bothered
figuring out how to do it "visually"
There kind of is, but only a static template! I created a user control
called ucTemplate in my project. Then you just go File -Export
Template -Item Template .. -Check the ucTemplate -Name it ..
Now when you go to create a new UserControl in your project, the
template shows up toward the bottom udner My Templates. The only
problem is that if you change your master template (like back ground
color) - the uc's created from the template don't update.

Feb 28 '07 #15
On Feb 28, 5:32 am, "Kbalz" <Kurtas.Balc...@gmail.comwrote:
On Feb 27, 8:36 pm, "Bruce Wood" <brucew...@canada.comwrote:

Your inherite way is the best since if you ever change the template
you are inheriting from, then all of your UC's will inherit those
changes.
I'm sure that there's some fancy way to do this in the Designer, but
it's so quick and easy to just tweak it that I've never bothered
figuring out how to do it "visually"

There kind of is, but only a static template! I created a user control
called ucTemplate in my project. Then you just go File -Export
Template -Item Template .. -Check the ucTemplate -Name it ..
Now when you go to create a new UserControl in your project, the
template shows up toward the bottom udner My Templates. The only
problem is that if you change your master template (like back ground
color) - the uc's created from the template don't update.
I just found the way to do it, but as I said, I never use it: right-
click the solution name in the Solution Explorer, choose Add Inherited
Control... and follow the prompts.

Feb 28 '07 #16
I struggle with this behavior for like 2 hours trying to handle the
keypress, keyup and keydown event, but it looks like the tabcontrol
don't care about this.
Now, according to your desing (which is the same one I'm implementing)
the only way I was able to workaround it was to handle the Selecting
event on the tab control and defining a local flag that would tell me
if is the "next" button the one moving to the next tab like the
following example

private void Tab_Move(object sender, EventArgs e)
{
Control ctr = sender as Control;
seletingInternally = true;
if (ctr.Text == "Next >>")
MoveTab(MoveTabDirection.Next);
else if (ctr.Text == "<< Back")
MoveTab(MoveTabDirection.Previous);
else if (ctr.Text == "Finish")
MoveTab(MoveTabDirection.Finish);
}

private void Tab_Selecting(object sender, TabControlCancelEventArgs e)
{
if (!selectingInternally) {
e.Cancel = true;
}

// always reset flag
selectingInternally = false;
}

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 aTabControl.. buttons on each tabPage move to the next or
previous tabPage.

When I pressCTRL+Tabhowever, thetabControlbegins to cycle through
the tabPages, just as it does in Visual Studio, IE7 etc.. any tabbed
program.

I need this blocked.

I am already catchingkeyinput 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
+tabkeystrokes, 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+tabfrom fliping my
tabPages? Basically using this method, it is possible to access my
adminTab from anytab, which I don't want.

I guess the alternative is to place a "onTabPageChanged" event to mytabcontrol, 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,

Mar 5 '07 #17
Check out the rest of this thread: TabControl isn't really suited to
building a wizard-style interface. UserControls dropped on a Form and
manipulated in code work much better.

On Mar 5, 2:00 pm, bernardo.balvan...@gmail.com wrote:
I struggle with this behavior for like 2 hours trying to handle the
keypress, keyup and keydown event, but it looks like the tabcontrol
don't care about this.
Now, according to your desing (which is the same one I'm implementing)
the only way I was able to workaround it was to handle the Selecting
event on the tab control and defining a local flag that would tell me
if is the "next" button the one moving to the next tab like the
following example

private void Tab_Move(object sender, EventArgs e)
{
Control ctr = sender as Control;
seletingInternally = true;
if (ctr.Text == "Next >>")
MoveTab(MoveTabDirection.Next);
else if (ctr.Text == "<< Back")
MoveTab(MoveTabDirection.Previous);
else if (ctr.Text == "Finish")
MoveTab(MoveTabDirection.Finish);
}

private void Tab_Selecting(object sender, TabControlCancelEventArgs e)
{
if (!selectingInternally) {
e.Cancel = true;
}

// always reset flag
selectingInternally = false;
}

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 aTabControl.. buttons on each tabPage move to the next or
previous tabPage.
When I pressCTRL+Tabhowever, thetabControlbegins to cycle through
the tabPages, just as it does in Visual Studio, IE7 etc.. any tabbed
program.
I need this blocked.
I am already catchingkeyinput 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
+tabkeystrokes, 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+tabfrom fliping my
tabPages? Basically using this method, it is possible to access my
adminTab from anytab, which I don't want.
I guess the alternative is to place a "onTabPageChanged" event to mytabcontrol, 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,- Hide quoted text -

- Show quoted text -

Mar 7 '07 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Henke | last post by:
I added a project to my solution that contains a user control. Now I 'd like to add the user control from that project to a form in my solution. The problem is that the control doesn't gets added...
2
by: Brian | last post by:
Greetings! What I am looking for is help trying to accomplish control + tab exiting subform #1 on page #1 and entering the first control (main form) on page #2. I've tried the following code,...
0
by: Kaki | last post by:
I have a RichTextBox with AcceptsTab set to true. When Ctrl is held down, pressing Tab does not trigger KeyPress or KeyDown/Up events. If AcceptsTab is false, the RichTextBox never knows if Tab...
3
by: Glen Hong | last post by:
I have set up a hotkey using RegisterHotKey API function for Ctrl-Tab. Firstly, I can rap this when Ctrl-Tab is pressed however if I want to add an addition hotkey how can I distinguish between...
3
by: raja11112222 | last post by:
Hi i used five pages in property sheet. when i click CTRL + Tab it goes to next pages, I want to stop this Scenario ie if i click CTRL + Tab, it wont goes to next page. How can i stop this...
10
by: thupham | last post by:
Dear all friend, I want disable Ctl+Alt+Del; Ctrl+Esc; Ctrl+tab, Alt+Tab, Start button, ctrl+Alt+Del, lock all keys on the keyboard. Have you ever do it in C#. Help me. Thanks for all reply.
56
by: csolomon | last post by:
Hello: I have something I would like to do and I was wondering if tab controls was the best route to accomplish it. I have 5 categories of material types. I created the application from an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.