Ok. Ich bin endlich zu Hause mit meinem Laptop. Also, was ich getan habe, um das gleiche zu tun, was Sie tun wollen, ist, dass ich ein ListView verwende, das ich dynamisch aus einer Datentabelle ausfülle. Hier ist der Code (Zusammenfassung dessen, was ich tue mit als am Boden nach Code):
For i = 0 To frmSelection.MechDataTable2.Rows.Count - 1
Dim tmpGroup As ListViewGroup = New ListViewGroup(frmSelection.MechDataTable2.Rows(i).Item("MechName"))
ltvMechs.Groups.Add(tmpGroup)
Dim tmpListItem1 As ListViewItem = New ListViewItem(tmpGroup)
Dim tmpListItem2 As ListViewItem = New ListViewItem(tmpGroup)
Dim tmpListItem3 As ListViewItem = New ListViewItem(tmpGroup)
Dim tmpListItem4 As ListViewItem = New ListViewItem(tmpGroup)
Dim tmpListItem5 As ListViewItem = New ListViewItem(tmpGroup)
'row1
tmpListItem1.SubItems.Add("co1")
tmpListItem1.SubItems.Add("co2")
tmpListItem1.SubItems.Add("co3")
tmpListItem1.SubItems.Add("co4")
tmpListItem1.SubItems.Add("co5")
tmpListItem1.SubItems.Add("co6")
tmpListItem1.SubItems.Add("co7")
tmpListItem1.SubItems(0).Text = "Select"
tmpListItem1.SubItems(1).Text = frmSelection.MechDataTable2.Rows(i).Item("Price")
tmpListItem1.SubItems(2).Text = frmSelection.MechDataTable2.Rows(i).Item("MechID")
tmpListItem1.SubItems(3).Text = "Faction Orientation"
tmpListItem1.SubItems(4).Text = frmSelection.MechDataTable2.Rows(i).Item("FactionOrientation")
tmpListItem1.SubItems(5).Text = "Engine HDP"
tmpListItem1.SubItems(6).Text = frmSelection.MechDataTable2.Rows(i).Item("EngineHardPoint")
'row2
tmpListItem2.SubItems.Add("co1")
tmpListItem2.SubItems.Add("co2")
tmpListItem2.SubItems.Add("co3")
tmpListItem2.SubItems.Add("co4")
tmpListItem2.SubItems.Add("co5")
tmpListItem2.SubItems.Add("co6")
tmpListItem2.SubItems.Add("co7")
tmpListItem2.SubItems(0).Text = ""
tmpListItem2.SubItems(1).Text = ""
tmpListItem2.SubItems(2).Text = ""
tmpListItem2.SubItems(3).Text = "Required Rep"
tmpListItem2.SubItems(4).Text = frmSelection.MechDataTable2.Rows(i).Item("RequiredRep")
tmpListItem2.SubItems(5).Text = "Generator HDP"
tmpListItem2.SubItems(6).Text = frmSelection.MechDataTable2.Rows(i).Item("GeneratorHardPoint")
'row3
tmpListItem3.SubItems.Add("co1")
tmpListItem3.SubItems.Add("co2")
tmpListItem3.SubItems.Add("co3")
tmpListItem3.SubItems.Add("co4")
tmpListItem3.SubItems.Add("co5")
tmpListItem3.SubItems.Add("co6")
tmpListItem3.SubItems.Add("co7")
tmpListItem3.SubItems(0).Text = ""
tmpListItem3.SubItems(1).Text = ""
tmpListItem3.SubItems(2).Text = ""
tmpListItem3.SubItems(3).Text = "Resilience"
tmpListItem3.SubItems(4).Text = frmSelection.MechDataTable2.Rows(i).Item("Resilience")
tmpListItem3.SubItems(5).Text = "Heavy HDP"
tmpListItem3.SubItems(6).Text = frmSelection.MechDataTable2.Rows(i).Item("HeavyHardPoint")
'row4
tmpListItem4.SubItems.Add("co1")
tmpListItem4.SubItems.Add("co2")
tmpListItem4.SubItems.Add("co3")
tmpListItem4.SubItems.Add("co4")
tmpListItem4.SubItems.Add("co5")
tmpListItem4.SubItems.Add("co6")
tmpListItem4.SubItems.Add("co7")
tmpListItem4.SubItems(0).Text = ""
tmpListItem4.SubItems(1).Text = ""
tmpListItem4.SubItems(2).Text = ""
tmpListItem4.SubItems(3).Text = "Weight"
tmpListItem4.SubItems(4).Text = frmSelection.MechDataTable2.Rows(i).Item("Weight")
tmpListItem4.SubItems(5).Text = "Medium HDP"
tmpListItem4.SubItems(6).Text = frmSelection.MechDataTable2.Rows(i).Item("MediumHardPoint")
'row5
tmpListItem5.SubItems.Add("co1")
tmpListItem5.SubItems.Add("co2")
tmpListItem5.SubItems.Add("co3")
tmpListItem5.SubItems.Add("co4")
tmpListItem5.SubItems.Add("co5")
tmpListItem5.SubItems.Add("co6")
tmpListItem5.SubItems.Add("co7")
tmpListItem5.SubItems(0).Text = ""
tmpListItem5.SubItems(1).Text = ""
tmpListItem5.SubItems(2).Text = ""
tmpListItem5.SubItems(3).Text = "Structure"
tmpListItem5.SubItems(4).Text = frmSelection.MechDataTable2.Rows(i).Item("Class")
tmpListItem5.SubItems(5).Text = "Light HDP"
tmpListItem5.SubItems(6).Text = frmSelection.MechDataTable2.Rows(i).Item("LightHardPoint")
ltvMechs.Items.Add(tmpListItem1)
ltvMechs.Items.Add(tmpListItem2)
ltvMechs.Items.Add(tmpListItem3)
ltvMechs.Items.Add(tmpListItem4)
ltvMechs.Items.Add(tmpListItem5)
Next
Grundsätzlich wird jedes Listenelement ist eine Zeile in der Gruppe, die jeweils subitem ist eine Zelle in der Zeile (ähnlich wie das, was Sie in Excel sehen würden, access ect.) subitem (0) ist in col1, subitem (1) ist in col2 ect. Für Ihre erste Spalte haben Sie den Unterpunkt (0) von listItem1 als Bild und alle anderen Unterpunkte (0) als leer. Wie ich oben in meinem Kommentar sagte, habe ich dies in vb.net codiert, aber bei allen Konten, die ich gesehen habe, ist es nicht viel anders als C#. Auch hier ist ein Bild von einem Teil dessen, was dieser Code produziert. Entschuldigung für die Qualität, aber es ist das Beste, was ich mit dem machen konnte, mit dem ich arbeiten musste. alt text http://img268.imageshack.us/img268/7977/listviewexample.png
Trauriges Gesicht im Extrem. Ich kann deine Frage jetzt nicht beantworten, aber ich habe genau das erstellt, worüber du mit VB.net sprichst und es sollte nicht so anders sein. Wenn ich nach Hause zu meinem Laptop komme, komme ich hierher und füge meinen Code ein und versuche, ein Bild von dem zu veröffentlichen, wie es aussieht, wenn es einmal gelaufen ist. Das einzige, worüber ich nicht sicher bin, ist, dass ich glaube, dass ich eine ListView anstelle einer DataGridView verwendet haben könnte. – Bryan