Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
namespace ListViewSample { using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using MySql.Data.MySqlClient; public class Form1 : System.Windows.Forms.Form { private System.ComponentModel.Container components; private MenuStrip menuStrip1; private ToolStripMenuItem programmToolStripMenuItem; private System.Windows.Forms.ListView listView1; public Form1() { InitializeComponent(); InitializeListView(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } private void InitializeComponent() { this.listView1 = new System.Windows.Forms.ListView(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.programmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // listView1 // this.listView1.ForeColor = System.Drawing.SystemColors.WindowText; this.listView1.FullRowSelect = true; this.listView1.GridLines = true; this.listView1.Location = new System.Drawing.Point(12, 61); this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(804, 168); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.View = System.Windows.Forms.View.Details; // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.programmToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(831, 24); this.menuStrip1.TabIndex = 1; this.menuStrip1.Text = "menuStrip1"; // // programmToolStripMenuItem // this.programmToolStripMenuItem.Name = "programmToolStripMenuItem"; this.programmToolStripMenuItem.Size = new System.Drawing.Size(67, 20); this.programmToolStripMenuItem.Text = "Programm"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(831, 297); this.Controls.Add(this.listView1); this.Controls.Add(this.menuStrip1); this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; this.Name = "Form1"; this.Text = "Bewerber"; this.Load += new System.EventHandler(this.Form1_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } protected void Form1_KeyDown (object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--) { ListViewItem li = listView1.SelectedItems[i]; listView1.Items.Remove(li); } } } public void InitializeListView() { ColumnHeader header1 = this.listView1.Columns.Add("Name", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header2 = this.listView1.Columns.Add("Nachname", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header3 = this.listView1.Columns.Add("Geburtstag", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header4 = this.listView1.Columns.Add("Name im Forum", 20 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header5 = this.listView1.Columns.Add("Team", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header6 = this.listView1.Columns.Add("Position", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header7 = this.listView1.Columns.Add("ICQ Nummer", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header8 = this.listView1.Columns.Add("E-Mail", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); ColumnHeader header9 = this.listView1.Columns.Add("Datum", 10 * Convert.ToInt32(listView1.Font.SizeInPoints), HorizontalAlignment.Center); } public static void Main(string[] args) { Application.Run(new Form1()); } private void Form1_Load(object sender, EventArgs e) { MySqlConnection connection = new MySqlConnection(Globals.ConnectionString); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM Daten"; MySqlDataReader Reader; connection.Open(); Reader = command.ExecuteReader(); while (Reader.Read()) { string[] Items = new String[]{ Reader.GetValue(1).ToString(), Reader.GetValue(2).ToString(), Reader.GetValue(3).ToString(), Reader.GetValue(4).ToString(), Reader.GetValue(6).ToString(), Reader.GetValue(7).ToString(), Reader.GetValue(9).ToString(), Reader.GetValue(10).ToString(), Reader.GetValue(12).ToString()}; } connection.Close(); } } } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// Create three items and three sets of subitems for each item. ListViewItem item1 = new ListViewItem("item1",0); // Place a check mark next to the item. item1.Checked = true; item1.SubItems.Add("1"); item1.SubItems.Add("2"); item1.SubItems.Add("3"); ListViewItem item2 = new ListViewItem("item2",1); item2.SubItems.Add("4"); item2.SubItems.Add("5"); item2.SubItems.Add("6"); ListViewItem item3 = new ListViewItem("item3",0); // Place a check mark next to the item. item3.Checked = true; item3.SubItems.Add("7"); item3.SubItems.Add("8"); item3.SubItems.Add("9"); ... //Add the items to the ListView. listView1.Items.AddRange(new ListViewItem[]{item1,item2,item3}); |
Werbeanzeige