Autor Beitrag
katmai
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35

Win xp

BeitragVerfasst: Do 04.12.08 15:44 
Hallo Ecken !

ich hab mir ein bissl was zusammengeschrieben wobei ich den Ihnalt meiner Textbox um ein zeichen kürze ...
dies hab ich per for schleife gamacht indem ich die Länge -1 als grenze für de For schleife gesetzt habe ...
nun habe ich das Problem dass der Curser am Anfang und nicht am ende steht ...

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
                tmp = "";
                for (i = 0; i < EEingabe.TextLength - 1; i++)
                {
                    tmp = tmp + EEingabe.Text[i];
                }
                EEingabe.Text = tmp;


wie kann ich die derzeitige position des Cursers im Textfeld rauskriegen und wie setzten ???

Danke schonmal im Vorraus für die Hilfe ...
bakachan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 503
Erhaltene Danke: 34

W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
BeitragVerfasst: Do 04.12.08 15:48 
Bei der TextBox gibt es eine Select-Funktion mit einer entsprechenden Überladung:
ausblenden C#-Quelltext
1:
textBox.Select(startIndex,length);					


und mal so nebenbei:
warum kürzt du den Text deiner TextBox so umständlich?
Benutze doch einfach Substring
ausblenden C#-Quelltext
1:
textBox.Text.Substring(startIndex, length);					

das liefert dir den entsprechenden Teil des Textes
katmai Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35

Win xp

BeitragVerfasst: Do 04.12.08 15:56 
Danke für den Tipp!
Zitat:

warum kürzt du den Text deiner TextBox so umständlich?


naja war mir nich in kopf gekommen *g* aber nochmal danke das du mich drauf bringst *g* ^^
katmai Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35

Win xp

BeitragVerfasst: Do 04.12.08 16:30 
soweit hat es geklappt ...

und wie bekommen ich den startwert also die aktuelle pos des cursers im textfeld raus ???
InCoBra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 43



BeitragVerfasst: Do 04.12.08 17:02 
Ganz einfach mit

ausblenden C#-Quelltext
1:
Int32 cursorPos = TextBox.SelectionStart					


und setzen halt mir

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
Int32 cursorPos = 25;
TextBox.SelectionStart = cursorPos;

// Eventuell noch (falls schon was ausgewählt ist)
TextBox.SelectionLength = 0;


MfG,
InCoBra
katmai Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35

Win xp

BeitragVerfasst: Do 04.12.08 17:07 
thx ! genau dat was ich suchte...
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Do 04.12.08 18:11 
Hallo Steffen,

damit Du künftig selbst fündig wirst: Gewöhne Dir doch an, selbst in der SDK-Doku/MSDN nachzulesen. Bei jeder Klasse stehen unter "Alle Member" alle Eigenschaften, Methoden und Ereignisse mit einer kurzen Beschreibung; damit findest Du schnell etwas, was eine bestimmte Maßnahme erreichen kann.

Jürgen