I'm new, I found examples here, but nothing works proper for me.
I'm just trying execute my program second way, but not sure how to figure out.
I want write some phrase in textBox1, then hit on enter, remove written phrase from textBox1, make some calculations and only then show this text in textBox2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace XX_TEXTBOX_TEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.AppendText("OK!");
}
}
}
if I go this way:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace XX_TEXTBOX_TEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
textBox2.AppendText("OK!");
}
}
}
}
I got error:
`Severity Code Description Project File Line Suppression State Error CS1061 'Form1' does not contain a definition for 'textBox1_TextChanged' and no extension method 'textBox1_TextChanged' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?) XX_TEXTBOX_TEST C:\FOLDER\Form1.Designer.cs 42 Active
And:
Severity Code Description Project File Line Suppression State Message The designer cannot process unknown name 'textBox1_TextChanged' at line 42. The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\FOLDER\Form1.Designer.cs 43
TextChanged
is only trigger when the text changed. you must use keydown event – Manu Varghese