CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    46

    C#.NET2008 Cannot close FRMSALES

    Hi Good Guys,

    Please help me, I need your help.

    I am a Newbie writing C#.Net 2008 Window Application.
    In the FRMSALES, to exit this form the users can either click on BTNEXIT or press the ESC Key but both of them are not working.

    Here is the error message:

    'System.EventArgs' does not contain a definition for 'KeyCode' and no extension method 'KeyCode' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)

    Here is the coding (C#.NET 2008)

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    private void btnexit_Click(object sender, System.EventArgs e)
    {
    this.Close;
    }

    private void FrmMain_KeyDown(Object sender, System.EventArgs e)
    {
    if (e.KeyCode = Keys.Escape)
    this.Close;
    }

    Thank you,

    Cheers,
    Lennie

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: C#.NET2008 Cannot close FRMSALES

    This can be done much easier.

    You only need the btnExit_click event. To make the form closing on Escape, set the form's CancelButton property to btnExit (or whatever you button is called)

  3. #3
    Join Date
    Jan 2005
    Posts
    46

    Re: C#.NET2008 Cannot close FRMSALES

    Hi dannyStommen,
    Thank you very much for sharing your knowledge with me. You are awesome and generous in sharing information. I have edited my code and tried it out and it's working. Yaaaa.....Hoooooo...
    I have learned something new as well.

    I am so glad to met you here. After my coding is working, I am trying to create a CONNECTTIONSTRING CLASS to be used by all the programs. I may come to you again asking for help.

    Thank you very much for your help.
    You have a Good Day.

    Cheers,
    Lennie
    Last edited by LennieKuah; March 29th, 2010 at 03:49 AM.

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