|
-
Jan 27th, 2006, 03:45 PM
#1
Thread Starter
Hyperactive Member
VB Equivilent in C#
What is the equivilent of "Exit Sub" in C#?
Also, what statement will cause the form to close if a condition isnt met? For example, I want to close a form if someoneclicks Cancel to open a file.
Thanks for all your patience!
Currently Using: VS 2005 Professional
-
Jan 27th, 2006, 04:44 PM
#2
Re: VB Equivilent in C#
"return"
To close a form, just use "this.Close()"
-
Jan 27th, 2006, 06:06 PM
#3
Thread Starter
Hyperactive Member
Re: VB Equivilent in C#
I did that but it still went through the form_load funciton anyways. Unless that will not work in form_load?
Currently Using: VS 2005 Professional
-
Jan 27th, 2006, 07:57 PM
#4
Re: VB Equivilent in C#
It would be of help if you could post the code you are currently using...
-
Jan 27th, 2006, 11:54 PM
#5
Re: VB Equivilent in C#
Once you call Show on a Form the Load event is raised and the Load event handler is executed. Even if you call Close within the Load event handler the the method will continue until it reaches and exit point and the form will be displayed, but only for a moment. If you want to do something first that will affect whether a form is displayed then do so before calling Show. Don't call Show if you don't, or might not, want to Show it.
-
Jan 27th, 2006, 11:57 PM
#6
Re: VB Equivilent in C#
you could make youself a new public function, like .TryShow on your form, which will test whatever it is you are etsting for, and from there it either calls .Show or doesnt.
this will save you having to modify your other code, and allow you to re-use it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|