Tabulatorgetrennt in ListBox?
-
Hallo zusammen
Wie ist es möglich, in einer ListBox eine Zeile mit Tabulator getrennten Einträgen hinzuzufügen?
Anstelle des Leerschlages unten, soll ein Tabulator hin...

str.Format("%s %s", ...); m_liste.AddString(str);
-
CString strText; strText.Format("%15s %15s %15d","String1","String2",15);
-
Danke sehr!
Kann ich nun das ganze auch noch irgendwie linksbündig hinkriegen?
Oder kennst du für diese Befehle (%s, %d, ...) eine brauchbare Übersicht, wo ich mich mal schlau machen könnte?
-
Linkbündig geht das so:
CString strText; strText.Format("%-15s %-15s %-15d","String1","String2",15);
-
Schau mal in jedem C Buch oder MS-Hilfe und den Funktionen printf, sprintf, ...
nach . Die nachfolgenden zwei Schnipsel sind aus der MSVC Hilfe, gefunden mit.In Visual C eines neues File mit der Extension C/Cpp erstellen
printf eintippen
F1 drückenFormat specifications always begin with a percent sign (%) and are read left to right. When printf encounters the first format specification (if any), it converts the value of the first argument after format and outputs it accordingly. The second format specification causes the second argument to be converted and output, and so on. If there are more arguments than there are format specifications, the extra arguments are ignored. The results are undefined if there are not enough arguments for all the format specifications.
Format Specification Fields: printf and wprintf Functions
A format specification, which consists of optional and required fields, has the following form:%[flags] [width] [.precision] [{h | l | I64 | L}]type
....
....:p Schade manchmal muss man auf den Boden der Tatsachen
pure C
zurück :pMit der Art von Formatierung Shlo benutzt du keine Tabs sondern formatierst den String in feste Felder.
In der normalen Listenfeld (Listbox) kannst bei den Eigenschaftn die Tabformatierung angeben.
Bei den Listenelementen (Listview) kannst du es zwar angeben,hat bei mir aber nicht funktioniert
-
Danke für eure Antworten!
Alles ist so, wie es auch sein sollte

-
Üblicherweise setzt man das Häkchen im Res-Editor unter "Tabstops" (2. Tab oben nicht Allgemein sondern Formate)
Mit CListBox::SetTabStops werden dann die einzelnen Abstände gesetzt.
CListBox* box = (...); box->SetTabStops(...); box->AddString(row1 + '\t' + row2 + '\t' + row3);