CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    Noida,India
    Posts
    96

    how to close a form

    hello gurus,

    i am a newbie in c#.Net 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.

    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.

    thanx

    vishal
    A small First step is the begining of any giant leap

  2. #2
    Join Date
    Apr 2004
    Posts
    55

    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.
    Last edited by BigEvil; February 13th, 2005 at 01:25 PM.

  3. #3
    Join Date
    Jan 2004
    Location
    Noida,India
    Posts
    96

    Re: how to close a form

    thanx dear,

    i'll try both of them

    thanx again
    A small First step is the begining of any giant leap

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured