Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Extended Textbox

Extended Textbox

Scheduled Pinned Locked Moved C#
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Greeky
    wrote on last edited by
    #1

    I extend a textbox for keypress event. a form includes one extended textbox and a button which is accept button of form. But when after editing text when u press Enter key , doesnt raise button_click event. How can pass this event to FORM when user press ENTER key after edit text.

    C F 2 Replies Last reply
    0
    • G Greeky

      I extend a textbox for keypress event. a form includes one extended textbox and a button which is accept button of form. But when after editing text when u press Enter key , doesnt raise button_click event. How can pass this event to FORM when user press ENTER key after edit text.

      C Offline
      C Offline
      cbhkenshin
      wrote on last edited by
      #2

      if your case what i understand that after the user enters or modify the text he/she will press enter and the form should the run the code for that button . so Simply select the form in the design Area and click F4 for properties the at go to Accept Button And choose your button. as simple as that if this was your case .

      P G 2 Replies Last reply
      0
      • C cbhkenshin

        if your case what i understand that after the user enters or modify the text he/she will press enter and the form should the run the code for that button . so Simply select the form in the design Area and click F4 for properties the at go to Accept Button And choose your button. as simple as that if this was your case .

        P Offline
        P Offline
        peshkunta
        wrote on last edited by
        #3

        Make sure in the Form properties the property KeyPreview is set to true. of if you can't find it there go to where the Form properties are initialized and put this code there: this.KeyPreview = true; //"this" refers to the Form //or KeyPreview = true; //but make sure the code is in the Form class //otherwise you'll get an error -- Don't worry about the world coming to an end today. It's already tomorrow in Australia --

        1 Reply Last reply
        0
        • C cbhkenshin

          if your case what i understand that after the user enters or modify the text he/she will press enter and the form should the run the code for that button . so Simply select the form in the design Area and click F4 for properties the at go to Accept Button And choose your button. as simple as that if this was your case .

          G Offline
          G Offline
          Greeky
          wrote on last edited by
          #4

          You got me wrong Form has a button and ExtendedTextbox textBox Button is already accept button of Form ExtendedTextbox has keypress event to control entry ,So if u press ENTER, this event handles enter key.

          P 1 Reply Last reply
          0
          • G Greeky

            You got me wrong Form has a button and ExtendedTextbox textBox Button is already accept button of Form ExtendedTextbox has keypress event to control entry ,So if u press ENTER, this event handles enter key.

            P Offline
            P Offline
            peshkunta
            wrote on last edited by
            #5

            I understand that, but you need to have KeyPreview = true; to be able to assign the AcceptButton property to a button for it to work without any extra code. (If the KeyPreview property is set to false, your case will only work if the only control on the Form is the button.) This is part of the code and it doesn't include the Form initialization where you need to put KeyPreview = true; This is all you need to be able to let's say write something in a textfield, press ENTER and even if your text still has focus it will work. But if you don't have the KeyPreview set to true, it will not. //********************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace ButtonPressedCsharpDELETETHIS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = "Button is pressed"; } } } //******************************************* -- Don't worry about the world coming to an end today. It's already tomorrow in Australia --

            G 1 Reply Last reply
            0
            • P peshkunta

              I understand that, but you need to have KeyPreview = true; to be able to assign the AcceptButton property to a button for it to work without any extra code. (If the KeyPreview property is set to false, your case will only work if the only control on the Form is the button.) This is part of the code and it doesn't include the Form initialization where you need to put KeyPreview = true; This is all you need to be able to let's say write something in a textfield, press ENTER and even if your text still has focus it will work. But if you don't have the KeyPreview set to true, it will not. //********************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace ButtonPressedCsharpDELETETHIS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = "Button is pressed"; } } } //******************************************* -- Don't worry about the world coming to an end today. It's already tomorrow in Australia --

              G Offline
              G Offline
              Greeky
              wrote on last edited by
              #6

              thanks friend i solved my problem

              1 Reply Last reply
              0
              • G Greeky

                I extend a textbox for keypress event. a form includes one extended textbox and a button which is accept button of form. But when after editing text when u press Enter key , doesnt raise button_click event. How can pass this event to FORM when user press ENTER key after edit text.

                F Offline
                F Offline
                fregolo52
                wrote on last edited by
                #7

                Hello, I would like to have this behavior too. What is your solution ? Please Freg.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups