DateTime – Aktueller Datum minus 20 Tage

In: CSharp
In Visual Basic gibt es die Funktionen DateAdd und DateDiff, mit denen man den DateTime manipulieren kann. Diese sind in CSharp .NET nicht implementiert. Ich hatte mir überlegt, wie ein Kollege aus Indien die Funktionen selbst zu implementieren, wie hier: DateDiff and DateAdd in C# Aber es geht einfacher mit einem zweizeiligen C# Code: DateTime […]

How to coloring every second row in ListView

In: CSharp
This c# code shows you how you coloring every second row in a ListView: int i = 0; foreach (ListViewItem item in listView1.Items) { if (i++ % 2 == 1) { item.BackColor = Color.LightGray; item.ForeColor = Color.BlueViolet; item.UseItemStyleForSubItems = true; } }

How to clear the items in ListView

In: CSharp
// Clear the ListView control listView1.Items.Clear();

How you can initialize ListView

In: CSharp
// Set the view to show details. listView1.View = View.Details; // Allow the user to edit item text. listView1.LabelEdit = true; // Allow the user to rearrange columns. listView1.AllowColumnReorder = true; // Select the item and subitems when selection is made. listView1.FullRowSelect = true; // Display grid lines. listView1.GridLines = true; // Sort the items […]
This c# code shows you, how to add a row in a listview: ListViewItem row = new ListViewItem(); row.SubItems.Add(value.ToString()); listview1.Items.Add(row); This creates 3 items and 3 subitems in a listview: // Create three items and three sets of subitems for each item. ListViewItem item1 = new ListViewItem("Item 1", 0); item1.SubItems.Add("Item1 Subitem 1"); item1.SubItems.Add("Item1 Subitem 2"); […]

How to add columns in listview

In: CSharp
This c# code creates columns with columnheader for the items and subitems in a listview. There are different ways to create columns. ColumnHeader column1 = new ColumnHeader(); column1.Width = 100; column1.Text = "Column 1"; column1.TextAlign = HorizontalAlignment.Right; listView1.Columns.Add(column1); listView1.Columns.Add("Column 2", 120, HorizontalAlignment.Center); // Width of -1 indicates to adjust the width of the longest item […]

Blogverzeichnis - Blog Verzeichnis bloggerei.de

Sponsors


Sponsors