-
how to close a form
hello gurus,
:wave: i am a newbie in c#.Net :D i am trying to close a form but by using application exit , the complete application closes while i wish to close the form only,i mean if i have two or more forms in the application then only one form wil be closed.
:confused:
:cry: my another problem is that how do i can check whether the text entered in the text box is in uppercase or in lower case.
i know that i'll get my answers as soon as possible.
so mnay thanx for all the gurus in advance. :wave:
thanx
vishal
-
Re: how to close a form
To close a form, use this.Close() in the close button's OnClick function
Code:
void btnClose(object sender, System.EventArgs e)
{
this.Close();
}
You can use regex to check if there are any uppercase and/or lowecase characters in the string.
Code:
Match m = Regex.Match(str, @"^[A-Z]+$");
if(m.Success)
...
The above will check if the entire string is in uppercase. For "[A-Z]+" , m.Success will be true if there is atleast one uppercase character in the string. Use whichever suits your needs.
To combine the two statements, you can use
Code:
if(Regex.Match(str, @"^[A-Z]+$").Success)
...;
The ^ and $ mean the beginning and end of the string respectively. + means one or more of the previous characters, * would mean 0 or more occurrences of the previous characters, just in case you don't know regular expressions. There might be a simpler way, but this is the only way I know, I too am a newbie in C# ;)
Regex is defined in System.Text.RegularExpressions, so don't forget to include this namespace.
-
Re: how to close a form
thanx dear,
i'll try both of them
thanx again :wave: