Exemplo n.º 1
0
        async private void CreateMyListView()
        {
            // Create a new ListView control.
            listView1.Bounds = new Rectangle(new Point(10, 40), new Size(1085, 445));

            // Adding sorting click handler || Joe
            listView1.ColumnClick += columnSort;

            // Set the view to show details.
            listView1.View = View.Details;
            // Allow the user to edit item text.
            listView1.LabelEdit = false;
            // Allow the user to rearrange columns.
            listView1.AllowColumnReorder = true;
            // Display check boxes.
            listView1.CheckBoxes = false;
            // Select the item and subitems when selection is made.
            listView1.FullRowSelect = true;
            // Display grid lines.
            listView1.GridLines = true;
            // Sort the items in the list in ascending order.
            listView1.Sorting = SortOrder.Ascending;

            listView1.Font = new Font("Consolas", 12f);
            ListViewItem etterem;

            try
            {
                restaurants = await db.ListRestaurants();

                for (int i = 0; i < restaurants.Count; ++i)
                {
                    etterem = new ListViewItem(restaurants[i].RestaurantName, i);

                    etterem.SubItems.Add(restaurants[i].DeliveryTime.ToString());
                    listView1.Items.Add(etterem);
                }
                //listView1.Columns.Add("UP", -2, HorizontalAlignment.Left);
                listView1.Columns.Add("Név", -1, HorizontalAlignment.Center);
                listView1.Columns.Add("Kiszállítási idő", -2, HorizontalAlignment.Center); listView1.Columns[1].Width = listView1.Columns[1].Text.Length * 12;

                // Add the ListView to the control collection.
                this.Controls.Add(listView1);
                refreshList();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }