示例#1
0
        /// <summary>
        /// Adds a sub-item to the list view item.
        /// </summary>
        /// <param name="itemText">The text of the sub-item.</param>
        public void AddSubItem(string itemText)
        {
            ListViewSubItem listViewSubItem = new ListViewSubItem();
            listViewSubItem.Text = itemText;

            SubItems.Add(listViewSubItem);
        }
示例#2
0
        /// <summary>
        /// Adds a sub-item to the list view item.
        /// </summary>
        /// <param name="itemText">The text of the sub-item.</param>
        public void AddSubItem(string itemText)
        {
            ListViewSubItem listViewSubItem = new ListViewSubItem();

            listViewSubItem.Text = itemText;

            SubItems.Add(listViewSubItem);
        }
示例#3
0
        private void OnDeleteFile(object sender, TouchEventArgs e)
        {
            if (Directory.GetCurrentDirectory() == "\\")
            {
                Debug.Print("Cannot delete from \\");
                return;
            }

            // If an item is selected, delete the item.
            if (_listView.SelectedItem != null)
            {
                // Get the sub-item that has the name.
                ListViewSubItem subItem = (ListViewSubItem)_listView.SelectedItem.SubItems[0];
                if (subItem != null)
                {
                    // If the name starts with [ and ends with ],
                    // then it is a directory.  This is only because
                    // we put the [ and ] on our directory names.
                    // There is nothing in the file system that
                    // requires the [ and ].
                    if ((subItem.Text[0] == '[') &&
                        (subItem.Text[subItem.Text.Length - 1] == ']'))
                    {
                        // Remove the [ and ].
                        string name = subItem.Text.Substring(1, subItem.Text.Length - 2);

                        // Make sure the directory exists.
                        if (Directory.Exists(name))
                        {
                            // Delete the directory.
                            Directory.Delete(name);

                            // Remove it from the list view.
                            _listView.RemoveItem(_listView.SelectedItem);
                        }
                    }
                    else if (File.Exists(subItem.Text))
                    {
                        // Without the [ and ], it is a file.

                        // Delete the file.
                        File.Delete(subItem.Text);

                        // Remove it from the list view.
                        _listView.RemoveItem(_listView.SelectedItem);
                    }

                    // Re-draw the list view.
                    _listView.Invalidate();
                }
            }
        }