Example #1
0
        /// <summary>
        /// Adds Ctrl+C and Ctrl+A shortcuts to the specified ListView.
        /// </summary>
        /// <param name="lv">The ListView to modify.</param>
        /// <param name="retrieveVirtualItem">A virtual item handler, if any.</param>
        public static void AddShortcuts(this ListView lv, RetrieveVirtualItemEventHandler retrieveVirtualItem)
        {
            lv.KeyDown +=
                (sender, e) =>
            {
                if (e.Control && e.KeyCode == Keys.A)
                {
                    if (retrieveVirtualItem != null)
                    {
                        for (int i = 0; i < lv.VirtualListSize; i++)
                        {
                            if (!lv.SelectedIndices.Contains(i))
                            {
                                lv.SelectedIndices.Add(i);
                            }
                        }
                    }
                    else
                    {
                        lv.Items.SelectAll();
                    }
                }

                if (e.Control && e.KeyCode == Keys.C)
                {
                    GenericViewMenu.ListViewCopy(lv, -1, retrieveVirtualItem);
                }
            };
        }
Example #2
0
        private void buttonCopy_Click(object sender, EventArgs e)
        {
            if (listLog.SelectedIndices.Count == 0)
            {
                for (int i = 0; i < listLog.VirtualListSize; i++)
                {
                    listLog.SelectedIndices.Add(i);
                }
            }

            GenericViewMenu.ListViewCopy(listLog, -1, listLog_RetrieveVirtualItem);
        }