Strings + Text Felder
-
Hi,
folgendes Problem :
Ich will einen String in einer TextBox ausgeben lassen, soweit so gut...
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace Passwort { public partial class Form1 : Form { string STRING; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { STRING = textBox1; textBox2 = STRING; } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } } }
So dann kommt folgende Fehlermeldung:
Error 1
Cannot implicitly convert type 'System.Windows.Forms.TextBox' to 'string' C:\C# Programmierung\PASSWORD\Passwort\Passwort\Form1.cs 38 22 PasswortError 2
Cannot implicitly convert type 'string' to 'System.Windows.Forms.TextBox' C:\C# Programmierung\PASSWORD\Passwort\Passwort\Form1.cs 39 24 PasswortDas versteh ich nicht...
Mir ist auch klar das ich es so machen könnte :
private void button1_Click(object sender, EventArgs e) { textBox1 = textBox2; }
Aber das muss doch auch mit Strings gehen oder?
mfg
-
Die TextBox hat die Eigenschaft Text
MessageBox.Show(textBox1.Text);
-
hää? ja und, ich will doch keine Message Box ausgeben lassen
ich will den inhalt von einem Textfeld in einen String kopieren !!
-
string s = textBox1.Text;
-
super danke