Autor Beitrag
vreden123
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95
Erhaltene Danke: 2



BeitragVerfasst: Do 14.04.11 19:24 
Hallo,

Wie kann ich am besten Bilder ein meiner Listview hinzufügen?
Ich habe schon gelesen das ich das mit einer Imagelist machen muss, aber ich verstehe nicht wie ich das am besten mache.

Text füge ich wie folgt hinzu:
ausblenden C#-Quelltext
1:
2:
3:
4:
string[] newHobby = new string[]
        { "hobby.Name""hobby.ClubName""hobby.MonthlyCost.ToString(\"C\")" };

      ListViewItem item = new ListViewItem(newHobby);
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 14.04.11 19:32 
Du packst eine ImageList auf dein Formular, fügst die Bilder hinzu und setzt die Eigenschaft LargeImageList / SmallImageList der ListView entsprechend.

Dann kannst du bei den einzelnen Items einfach ImageIndex entsprechend des Indexes in der ImageList setzen, fertig.
vreden123 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95
Erhaltene Danke: 2



BeitragVerfasst: Do 14.04.11 21:29 
und wie genau?

weil ich kann ja nur texte hinzufügen und keine bilder.
Oder wo liegt da der Denkfehler?
vreden123 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95
Erhaltene Danke: 2



BeitragVerfasst: Do 14.04.11 22:28 
Ich möchte das Bild auch nicht ganz links einfügen sondern in einer spalte.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 15.04.11 05:56 
user profile iconvreden123 hat folgendes geschrieben Zum zitierten Posting springen:
Ich möchte das Bild auch nicht ganz links einfügen sondern in einer spalte.
Das war die wichtige Information...

Das ist so nicht vorgesehen, ich denke da musst du das selbst zeichnen. Dafür gibt es DrawSubItem als Ereignis. Darin kannst du dann den Inhalt (in deinem Fall das Bild plus der Text) der Zelle selbst zeichnen.
vreden123 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95
Erhaltene Danke: 2



BeitragVerfasst: Fr 15.04.11 12:08 
Und wie verwende ich dieses "DrawSubItem"? Wie Zeichne ich den das Bild/Icon?
m-s
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149
Erhaltene Danke: 7

Win 10
C# (VS 2015)
BeitragVerfasst: Fr 15.04.11 12:19 
user profile iconvreden123 hat folgendes geschrieben Zum zitierten Posting springen:
Und wie verwende ich dieses "DrawSubItem"? Wie Zeichne ich den das Bild/Icon?

Schreib in Deinen Code

ausblenden C#-Quelltext
1:
2:
ListView list = new ListView();
list.DrawSubItem

und drücke sofort F1

_________________
Gruß Markus
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 15.04.11 12:24 
Vollkommen überraschend steht das in der Dokumentation beschrieben, sogar mit Beispiel:
msdn.microsoft.com/d...iew.drawsubitem.aspx
vreden123 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95
Erhaltene Danke: 2



BeitragVerfasst: Fr 15.04.11 12:43 
Ja auf der Microsoft seite war ich bereits.

Aber wenn ich das in mein Projekt hinzufüge, dann wird in dem Beispiel 2 Fehler angezeigt. Undzwar das:

NumberFormatInfo
NumberStyles.Currency

nicht in dem Projekt enthalten sind.
Deswegen stelle ich ja meine Frage, weil ich nicht weiß woran das liegt.
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Fr 15.04.11 12:57 
Dann such nach diesen Stichworten und binde die dafür nötigen Namensbereiche (namespace) ein.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 15.04.11 14:13 
user profile iconvreden123 hat folgendes geschrieben Zum zitierten Posting springen:
Aber wenn ich das in mein Projekt hinzufüge, dann wird in dem Beispiel 2 Fehler angezeigt.
Und du meintest es wäre sinnvoller das einfach einmal nicht zu erwähnen? Meine Glaskugel ist leider gerade in Reparatur... :roll:

Visual Studio bietet dir doch direkt eine Autokorrektur an:

CsAutoCorrection

Dort kannst du einfach eine von beiden Möglichkeiten anklicken und fertig.
Einloggen, um Attachments anzusehen!