Backspace key to return previous form

I want to return to previous form in C# using backspace key. I am using KeyDown event on form to check for backspace key . but the form is not detecting any key down event.

How can I achieve this?

private void History_P_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData.ToString() == "Back") MessageBox.Show("Back button pressed"); }

where History_P is form name.

-------------Problems Reply------------

You need to enable the KeyPreview property on the Form.

With this property the key being pressed (all KeyUp, KeyDown, KeyPressed events) will first be caught by the Form and is then passed on to the control that is focused at that moment, unless you set the KeyPressEventArgs.Handled to true.

Category:c# Views:2 Time:2018-12-16
Tags: winforms

Related post

  • Pretty key names in C# (Forms) 2012-04-03

    I have a combobox which is populated by the Keys enumeration (winforms). The problem is that the key names are not very clear for inexperienced users. For example, the average user may not know what 'OemPipe', or 'HanjaMode' means. So, how can I solv

  • Backspace key in Silverlight text box shows previous page in Safari instead of editing text 2011-02-24

    I have a web page with some embedded Silverlight. In that Silverlight I have a text box. If I'm using Safari and I hit the backspace key while editing that Silverlight text box, Safari goes back a page as if I had clicked the "show the previous page"

  • when I press the backspace key, instead of deleting the previous character it highlights the entire document 2014-09-16

    Original title: Backspace key When I'm writing my document, occasionally when I press the backspace key, instead of deleting the previous character it highlights the entire document as if I'd pressed Ctrl+A. If I press the button a second time it per

  • On iOS 8, auto-fill webapp login form doesn't work without the use of the backspace key 2014-11-13

    I'm designing a login form for my web application, it works greatly on most browsers but I get a very strange behavior with iOS 8 on my iPhone 5 Steps to reproduce it : open Safari, complete the login form save the credential (as requested by safari)

  • Disabling backspace key works in all browsers but IE 2011-06-10

    I'm trying to disable the backspace button on an order page in all cases except when a textarea or text input is an active element to prevent users from accidentally backing out of an order. I have it working fine in most browsers, but in IE (testing

  • How can I prevent the backspace key from navigating back? 2009-09-29

    On IE I can do this with the (terribly non-standard, but working) jQuery if ($.browser.msie) $(document).keydown(function(e) { if (e.keyCode == 8) window.event.keyCode = 0;}); But is it possible to do in a way which works on Firefox, or in a cross-br

  • How to trap the backspace key using jQuery? 2011-02-08

    It does not appear the jQuery keyup, keydown, or keypress methods are fired when the backspace key is pressed. How would I trap the pressing of the backspace key? --------------Solutions------------- try this one : $('html').keyup(function(e){if(e.ke

  • Backspace key in Outlook 2010 calendar often flips the screen to another folder 2012-02-19

    I'm having an issue similar to the one described here: http://help.lockergnome.com/office/backspace-key-returns-outlook-today--ftopict415630.html ...but I can't find a response. I'm in Outlook 2010, with two windows open-- inbox on the right monitor,

  • TextField() - filter backspace key away with event listener 2009-02-12

    How to prevent a specific key such as backspace key functioning from TextField editable field, preventDefault does not seem to work: public function handleEvents(evt:KeyboardEvent):void { if (evt.type == KeyboardEvent.KEY_UP) { if (evt.keyCode==8){ e

  • How can I accept the backspace key in the keypress event? 2009-07-28

    This is my code: private void txtAdd_KeyPress(object sender, KeyPressEventArgs e) { if (!(char.IsLetter(e.KeyChar)) && !(char.IsNumber(e.KeyChar)) && !(char.IsWhiteSpace(e.KeyChar))) { e.Handled = true; } } It allows me to enter lette

  • How do I capture the enter key in a windows forms combobox 2009-08-04

    How do I capture the enter key in a windows forms combo box when the combobox is active? I've tried to listen to KeyDown and KeyPress and I've created a subclass and overridden ProcessDialogKey, but nothing seems to work. Any ideas? /P --------------

  • convert the key in MIME encoded form in python 2009-09-14

    this is the code : f = urllib.urlopen('http://pool.sks-keyservers.net:11371/pks/lookup?op=get&search= 0x58e9390daf8c5bf3') #Retrieve the public key from PKS data = f.read() decoded_bytes = base64.b64decode(data) print decoded_bytes i need to conv

  • How do I pass the value of the previous form element into an "onchange" javascript function? 2009-10-01

    I want to make some UI improvements to a page I am developing. Specifically, I need to add another drop down menu to allow the user to filter results. This is my current code: HTML file: <select name="test_id" onchange="showGrid(this.name, this.va

  • insert data to the database, and then get an autogenerated int key in return 2009-10-04

    Couldn't find a method like the int executeUpdate(String sql, int autoGeneratedKeys) in php. I want to insert data to the database, and then get an autogenerated int key in return (the ID). Thanks :) Oh, and PS: it has to be a method from the mysqli

  • Could not send backspace key using ::SendInput() to wordpad application 2010-03-10

    I have used sendinput() function and windows keyboard hooks to develop a custom keyboard for indian languages. Project is in google code here: http://code.google.com/p/ekalappai The keyboad hook and sendinput functions are placed in a win32 dll. And

  • Command Binding And The Backspace Key 2010-05-10

    I need to bind a command to the Backspace key. The command needs to be enabled when keyboard focus is in a textbox, which in turn is inside of the DataTemplate for an ItemsControl. The following code doesn't seem to acknowledge that the backspace key

  • SQL query that returns columns form table A plus a bit column that specifies whether the PK of table A exists in table B 2010-05-21

    How can I write an efficient SQL query that returns columns form table A plus a bit column that specifies whether the PK of table A exists in table B? I am using MS SQLServer 2005. Thanks. --------------Solutions------------- It depends if the foreig

  • How to catch key press on a form c# .net 2010-06-08

    I have a parent form that contains a lot of controls. What I am trying to do is filter all of the key presses for that form. The trouble is that if the focus is on one of the controls on the form then the parent form is not getting the key press even

  • SWT java browser backspace key stops working 2010-07-12

    I open a web page in my java program's swt browser. Sometimes the backspace key stops working. has anyone heard of this or know what may fix it? When i click a button on my swt form the backspace key inside of the browser starts working again. ------

  • defeating the enter key from doing a form submit 2010-10-06

    I've found several jQuery syntaxes for nullifying the enter on a form. First one: $("form input[@type=text]").bind("keypress", function(e) { var code=e.charCode || e.keyCode; return (code==13)?false:true; }); Second one: $("form").bind("keypress", fu

  • how to define short key for scroll in form in c# 2010-10-13

    how to define short key for scroll in form in c# --------------Solutions------------- The default keys for scrolling are the arrows. If you want to redefine them with new keys, you can override your control's ProcessCmdKey method and use the arrows w

  • How to pass previous form data to the constructor of a DynamicForm in FormWizard 2010-10-15

    I have a FormWizard where I need data from the first form to pass to the constructor of the second form so I can build a dynamic form. I can get the first form's data via the process_step of the FormWizard. I create the fields of the second form with

  • returning address form a function 2011-02-18

    i have returned address form a function search(keys), like this return ptr->keys[pos] where ptr->keys[pos].value was used to access the member function of keys. is the above return statement correct? does this return the address after it return

  • DEL and BACKSPACE keys get eaten from WebBrowser 2011-05-19

    I have a custom task pane in a VSTO Outlook add-in which hosts a System.Windows.Forms.WebBrowser control. All works well but in web forms DEL and BACKSPACE keys do not work. As if something eats those keys before they get to the browser. Any pointers

  • go back to the previous form (c#) 2011-06-07

    i know how to go to another form in modal mode just like what i did below: public partial class Form1 : Form { public Form1() { InitializeComponent(); } Form2 myNewForm = new Form2(); private void button1_Click(object sender, EventArgs e) { this.Hide

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.156 (s). 11 q(s)