listview c# code example

Example 1: c# listview

lvRegAnimals.View = View.Details;

lvRegAnimals.Columns.Add("Id", -2, HorizontalAlignment.Left);
lvRegAnimals.Columns.Add("Name", -2, HorizontalAlignment.Left);
lvRegAnimals.Columns.Add("Age", -2, HorizontalAlignment.Left);

Example 2: C# listview as listbox

this.listView1.View = View.Details;
this.listView1.HeaderStyle = ColumnHeaderStyle.None;
this.listView1.FullRowSelect = true;
this.listView1.Columns.Add("", -2);
this.listView1.Items.Add("Something");
this.listView1.Items.Add("Something else").BackColor = Color.Red;

Example 3: listview

class YourView(ListView):
	model				= YourModel
    paginate_by			= your_pagination_number
    context_object_name = 'your_model_in_plural'
    template_name 		= 'your_list.html'

Tags:

Misc Example