Okay so I am creating a program (well more an application as it's becoming alot of coding). But anyway, I have created multiple forms for it but I can't figure how to keep the form on top. I have found the code

this.TopMost = true;

But that only keeps the the form on top of the other forms, but what I need to figure out is how to prevent the user from selecting the other forms. You know like when you save a document nad the dialog pops up it won't let you click on the doument it just makes that beeping sound. I hope I am making sense. (oh also if I do this.Close() for the form with that make TopMost false)

Oh and thanks

What you're looking for is a Modal form.

This is something that comes up often enough around here so here's a link to a previous thread where a modal dialogue was discussed (please don't post in the old form though, if you have questions about what is discussed there please post them here).

That would suit the needs as you've stated them.

Hope it helps :) Please remember to mark this thread solved once your issue is resolved.

commented: Yes! +7
commented: exactly right :) +1

Okay I am alittle confused by what to do. Here is what I have

shiftAlter_edit_Form6 form6 = new shiftAlter_edit_Form6(storedFileArray, loc);
        form6.FormClosing += new FormClosingEventHandler(editShift);
        form6.Visible = true;
        form6.Location = new Point(this.Location.X + 62, this.Location.Y + 40);

And then when in the form I use


To close the form.

Am I on the right track?

Not even :/
Did you check the link Lusipher posted? It showed you how to use a modal form:

shiftAlter_edit_Form6 form6 = new shiftAlter_edit_Form6(storedFileArray, loc);

Code execution will pause on the current form until form6 is closed. You wont be able to move focus to any other forms. You can also make use of the DialogResult property in the modal form to tell the parent form what the outcome was such as DialogResult.OK or DialogResult.Cancel.

Ryshad's will solve your problem. Just use that code freely. Don't go for big blow coding. OK

ya, I go with Shashank, Rysha's code will work fine,
ShowDialog() method will not allow u to choose any other form until you complete the process on the form where you have given ShowDialog() for.

Whilst i appreciate the cheering section, is it really necessary to refresh a post just to say that i was right...without adding anything to the discussion?

commented: I was thinking the same thing myself :P +1
commented: Quite so +1

I mean seriously... Especially when it was ME who was right first :'(

LoL Sorry, had to say it Ryshad. And I agree completely with what you said but um... now you and I are both guilty of refreshing the thread to point out that the thread didn't need to be refreshed :twisted:

Hey sorry it took me so long to get back to you guys I have been buzy, I will try this when I get a chance and let you know.

Well it seems to work I need to run some more tests, but it looks good. I left that closing statement in at the moment, but I'll look of pulling that after some testing