程序员面试题精选(17):把字符串转换成整数

开发经常遇到的。如果你有兴趣,可以帮忙微软扩展一下ListView

在用ListView时,想删除选择项,单选的删除很简单

这里讲一下多选的

首先我们响应的事件为ListView.KeyDown

因为我们要检查的是否按下delete键

代码如下:

 /// <summary>
        /// key “Delete” is pressed,and then Delete All of ListView SelectedItems
        /// </summary>
        /// <param ></param>
        /// <param ></param>
        private void lvFolderStatusList_KeyDown(object sender, KeyEventArgs e)
        {
            if (lvFolderStatusList.SelectedItems != null)
            {
                if (e.KeyCode == Keys.Delete)
                {
                    int nMaxSelect=lvFolderStatusList.SelectedItems.Count;
                    for (int i = 0; i <nMaxSelect ;nMaxSelect--)
                    {
                        lvFolderStatusList.Items.RemoveAt(lvFolderStatusList.SelectedItems[0].Index) ;
                    }
                }
            }

 

你可能感兴趣的:(面试,ListView,object,null,delete,扩展)