Click here to Skip to main content
12,896,175 members (52,860 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#3.0 C# User-controls
Hi to all of you, this is my first post on Code Project and I need help and/or ideas on how to implement a user control that would have a modal behavior.

My only problem is that I CAN'T be using any kind of form.

I already try this approach and it is not doing what we need it to do.

Our problem is that the application we are developing with C# 3.0 is a full screen application with security to enforce the user to stay in the application.

We are not using other forms because it would force the taskbar to appear and disable the main security of the parent full screen form.

So everything in the main form is a user control.

If you happen to know that this is not possible, could you simply elaborate a little more to explain with this is not possible.

Thanks for you're help and you're answer, cheer.
Posted 15-Sep-12 2:53am
Wes Aday 15-Sep-12 9:02am
"I CAN'T be using any kind of form", so what kind of container capable of containing user controls are you using?
Philippe Mercure 15-Sep-12 9:20am
No I am using a form for the main form, but I cannot put the user control that we want to be modal in a new form and then just show this form. It need to be a user control in the main form with a modal behavior, sorry for the misunderstood.
Wes Aday 15-Sep-12 9:24am
Sorry that makes no sense to me. Trying to use a modal form without using a modal form sounds like a poor design to me. Maybe someone else has some other ideas. Good luck.
Philippe Mercure 15-Sep-12 9:29am
Ok maybe try it another way around, you need to create a full screen application with security to disable the start menu Alt+Tab and stuff like this. We already create a bunch of user control, but all of them are being use at the same time, like a UserControlClock and a UserControlDate. With all those user control we now need to ask the user if he want to delete or not something, basically we need the user to answer a question, Yes No. How would you do if you were not able to create a new form. Their must be a way with event, delegation, timer or a mix of them, to assure you that the user select Yes or No, before the main form can continue it execution.
Ed Nutting 15-Sep-12 9:29am
Your question is very unlcear at the moment and really doesn't make much sense. Please use the Improve Question link above to create a re-worded version of it. Perhaps get a colleague to look it over or something?

Wes Aday 15-Sep-12 9:31am
That exact thing that you are describing is called a MessageBox
Philippe Mercure 15-Sep-12 9:32am
Could you elaborate on what is not clear, ???
Philippe Mercure 15-Sep-12 9:37am
Mmmm, ok, so we might not have a choice but use a custom form in modal mode. I was trying to avoid this. I'll try to limit the impact. Thanks for you help, :).
Ed Nutting 15-Sep-12 9:39am
Erm.. all of it? You start by saying you can't use any kind of Form but then say that you are using a Form for your Main Form - that doesn't make sense. Then you say that you want to put a User Control in a Form but not using a Form - really confused here.

I suggest you listen to Wes Aday, he is right when he says you should use a MessageBox (with Yes/No button options used not default buttons - see MSDN documentation). This shouldn't show the Task Bar.

I would just like to point out though that all your efforts are defeated by one simple fact - you cannot disable Ctrl+Alt+Delete! Any user could just Ctrl+Alt+Delete and get out of your program without too much difficulty. Edit: Unless your company will be disabling many of the useful Ctrl+Alt+Delete features, notably Task Manager, on every client computer.

Philippe Mercure 15-Sep-12 9:44am
Yes that's what we are doing with the Ctrl+Alt+Delete, thanks for you help, I'll try to be using the MessageBox, if I found another solution I'll try to post it here, thanks again, :).

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I found the solution to my problem, to have a UserControl have the behavior of a modal form.

It was pretty easy.

Just by using event handlers, I was able to hook up to the UserControl Yes and No button, then by displaying this UserControl full screen on the main form, would act like a modal form.

Thanks all for you're help, :).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 15 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100