Veröffentlicht 10. November 200915 j Hi ich möchte mehrere anweisung in einer TextBox ausgeben alledings bekomme ich das nicht so hin. for (int umsatz = 25500; umsatz <= 40000; umsatz = umsatz + 500) { if (umsatz == 30000) { double ausgabe1z1 = 30000 * 0.05 +1000; double ausgabe2z2 = 30000 * 0.08; txt_reisender.Text = Convert.ToString(ausgabe1z1)"; txt_Vertreter.Text = Convert.ToString(ausgabe2z2); } if (umsatz == 30500) { double ausgabe3z1 = 30500 * 0.05 + 1000; double ausgabe4z2 = 30500 * 0.08; txt_reisender2.Text = Convert.ToString(ausgabe3z1); txt_vertreter2.Text = Convert.ToString(ausgabe4z2); } if (umsatz == 31000) { double ausgabe5z1 = 31000 * 0.05 + 1000; double ausgabe6z2 = 31000 * 0.08; txt_reisender.Text = Convert.ToString(ausgabe5z1) ; txt_Vertreter.Text = Convert.ToString(ausgabe6z2); Ich weis das die Text box die Eigenschaften : Multiline und scrolbars haben muss Allerding wird immer nur eine Zahl in der TextBox ausgegeben. Wie kann ich jetzt alle Ergebnise der Rechnungen in einer bzw zwei TextBoxen ausgeben ohne das die vorran gegangen Ergebnise überschrieben werden ? ich habe es jetzt schon Probiert mit: z.b. txt_Vertreter.Text = Convert.ToString(ausgabe1z1) + "t" +"\r\n"; oder txt_vertreter.Text = "Convert.ToString(ausgabe1z1)" +"t" "Convert.ToString(ausgabe2z2)" + "\r\n"; Aber das funktioniert auch nicht wie auch
10. November 200915 j Ich weis das die Text box die Eigenschaften : Multiline und scrolbars haben muss Allerding wird immer nur eine Zahl in der TextBox ausgegeben. Typically, a TextBox control is used to display, or accept as input, a single line of text. You can use the Multiline and ScrollBars properties to enable multiple lines of text to be displayed or entered. Set the AcceptsTab and AcceptsReturn properties to true to enable greater text manipulation in a multiline TextBox control. Note: You must set the Multiline property to true to adjust the height of the TextBox control. You can adjust the height by setting the Size property. Ergo: Multiline auf true gesetzt? Höhe angepasst? Wie kann ich jetzt alle Ergebnise der Rechnungen in einer bzw zwei TextBoxen ausgeben ohne das die vorran gegangen Ergebnise überschrieben werden ? Wenn das mit der Textbox nicht klappt, könnte man die Richtextbox als TextArea "missbrauchen".
10. November 200915 j Autor Ergo: Multiline auf true gesetzt? Höhe angepasst? gemacht =) Ich hab es jetz so hinbekommen: if (umsatz == 34000) { double ausgabe17z1 = 34000 * 0.05 + 1000; double ausgabe18z2 = 34000 * 0.08; listBox1.Items.Add(ausgabe17z1); listBox2.Items.Add(ausgabe18z2); if (ausgabe17z1 > ausgabe18z2) { listBox3.Items.Add(reisender); } else { listBox3.Items.Add(vertreter); } ISt also beantwortet aber trozdem danke für die Antwort
10. November 200915 j Du hast jetzt statt ner Textbox ne Listbox genommen. Okay, wenns funktioniert. Für die Textbox gibts aber auch die Methode "AppendText". public partial class Form1 : Form { /// <summary> /// Append a line to the TextBox, and make sure the first and last /// appends don't show extra space. /// </summary> /// <param name="myStr">The string you want to show in the TextBox.</param> private void AppendTextBoxLine(string myStr) { if (textBox1.Text.Length > 0) { textBox1.AppendText(Environment.NewLine); } textBox1.AppendText(myStr); } /// <summary> /// Just a test method that shows the above code being used. /// </summary> private void TestMethod() { for (int i = 0; i < 2; i++) { AppendTextBoxLine("Some text"); } } } Sowas ähnliches hab ich mal gebraucht um bestimmte Strings aus einem Eingabetext zu lesen. Irgendwo hier schwirrt auch noch meine Frage dazu rum, wo es dann schließlich so gelöst wurde die Textbox nicht zu aktualisieren sondern den String an ein Array anzuhängen und erst am Schluss in die Textbox zu schreiben.
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.