Autor Beitrag
Geneesys
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: Do 24.05.12 12:56 
Mahlzeit alle zusammen,

Ich habe bis jetzt ein kleines Programm geschireben das den Inhalt einer txt Datei in eine RichTextBox einfügt. Nun möchte ich aber mit einem Button in dem inhalt der RichTextBox suchen.
Sagen wir mal .. 123456. Nun soll er die Box nach 123456 durchsuchen und durch ABCDE ersetzen.ISt sowas möglich ?

Danke im voraus (:

Gruß
Geneesys


Moderiert von user profile iconTh69: Topic aus C# - Die Sprache verschoben am Do 24.05.2012 um 15:48
mats74
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189
Erhaltene Danke: 26

Win 10
VS 2017/19, C++, C#
BeitragVerfasst: Do 24.05.12 13:51 
Hallo Geneesys

Das kannst Du mit der Replace-Methode sehr einfach lösen:
ausblenden C#-Quelltext
1:
richTextBox1.Text = richTextBox1.Text.Replace("suche nach dem""ersetze mit dem");					

_________________
Gruss
mats74

Für diesen Beitrag haben gedankt: Geneesys, Lihlu
Lihlu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 53



BeitragVerfasst: Do 24.05.12 14:07 
Danke dir vielmals :)
Ich war ebenfals auf der suche nach soetwas in der art :)
Geneesys Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: Do 24.05.12 14:27 
Hey danke dir erstmal für deine Antwort,

Eine kleine frage habe ich noch dazu ...
ausblenden C#-Quelltext
1:
richTextBox1.Text = richTextBox1.Text.Replace(TextBox1 , TextBox2);					

Wie bekomme ich es hin das es auch so funktioniert ?
Oder funktioniert es mit TxtBoxen überhaupt ?

Gruß
Geneesys

Moderiert von user profile iconTh69: C#-Tags hinzugefügt
mats74
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189
Erhaltene Danke: 26

Win 10
VS 2017/19, C++, C#
BeitragVerfasst: Do 24.05.12 14:40 
... da fehlt bei Dir noch der Textinhalt der TB's den Du in der Abfrage setzen willst.
Du kannst nicht einfach den Controlnamen der TB's in Klammern schreiben, Du musst die Text-Eigenschaft (Inhalt) noch dazusetzen :wink: .

_________________
Gruss
mats74