{"id":3122,"date":"2020-02-14T11:49:43","date_gmt":"2020-02-14T02:49:43","guid":{"rendered":"http:\/\/kats-eye.net\/info\/?p=3122"},"modified":"2020-02-14T20:00:30","modified_gmt":"2020-02-14T11:00:30","slug":"c-list%e2%80%90image-04","status":"publish","type":"post","link":"https:\/\/kats-eye.net\/info\/2020\/02\/14\/c-list%e2%80%90image-04\/","title":{"rendered":"C# ListView\u9593\u306e\u30de\u30a6\u30b9D&#038;D\u306b\u3088\u308b\u5199\u771f\u306e\u79fb\u52d5\u3068\u30b3\u30d4\u30fc"},"content":{"rendered":"<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2.63291%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff; width: 96.2025%;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">listView\u9593\u306e\u753b\u50cf\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u00a0<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-size: 14pt;\">\u3000C# listView\u95a2\u4fc2\u306e\u307e\u3068\u3081\u3068\u3057\u3066\u3001\u540c\u3058 listView\u5185\u3060\u3051\u3067\u306a\u304f\u3001\u7570\u306a\u308b listView\u9593\u306e\u753b\u50cf\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u304c\u51fa\u6765\u308b\u69d8\u306b\u691c\u8a0e\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u4e0b\u56f3\u306f\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u8d77\u52d5\u5f8c\u3001\u753b\u50cfNo\u3014\uff15\u3015\u3014\uff16\u3015\u3014\uff18\u3015\u3092\u9078\u629e\u3057\u305f\u72b6\u614b\u3067\u3059\u3002<img loading=\"lazy\" class=\"aligncenter size-full wp-image-3126\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/002-2.png\" alt=\"\" width=\"1017\" height=\"636\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/002-2.png 1017w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/002-2-300x188.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/002-2-768x480.png 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><br \/>\n<span style=\"font-size: 14pt;\">\u3000\u6b21\u306e\u56f3\u306f\u9078\u629e\u3057\u305flistView1\u306e\u753b\u50cf\u3092listView2\u306b\u79fb\u52d5(Move)\u3057\u305f\u72b6\u614b\u3067\u3059\u3002\u3000<\/span><br \/>\n<img loading=\"lazy\" class=\"aligncenter size-full wp-image-3127\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/003-2.png\" alt=\"\" width=\"1017\" height=\"636\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/003-2.png 1017w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/003-2-300x188.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/003-2-768x480.png 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><br \/>\n<span style=\"font-size: 14pt;\">\u3000\u6b21\u306e\u56f3\u306f\u9078\u629e\u3057\u305flistView1\u306e\u753b\u50cf\u3092listView2\u306b\u30b3\u30d4\u30fc(Copy)\u3057\u305f\u72b6\u614b\u3067\u3059\u3002<\/span><img loading=\"lazy\" class=\"aligncenter size-full wp-image-3128\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/004-2.png\" alt=\"\" width=\"1017\" height=\"636\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/004-2.png 1017w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/004-2-300x188.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/004-2-768x480.png 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><\/span><br \/>\n<span style=\"font-size: 14pt;\">\u3000\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u306f\u3001listView2 \u304b\u3089 listView1 \u306e\u53cd\u5bfe\u65b9\u5411\u3082\u53ef\u80fd\u3067\u3059\u3002<\/span><\/p>\n<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2.63291%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff; width: 96.2025%;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">\u30d7\u30ed\u30b0\u30e9\u30e0<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-size: 14pt;\">\u3000\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3057\u3066\u306f\u3001\u904e\u53bb\u6295\u7a3f\u306e\u5fdc\u7528\u3067\u3059\u3002\u60a9\u3093\u3060\u3068\u3053\u308d\u306f\u3001\u2460\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u6642\u306b\u5143\u30c7\u30fc\u30bf\u304c\u540c\u3058\u3001\u3082\u3057\u304f\u306f\u4ed6\u65b9\u306elistView\u306a\u306e\u304b\u5224\u5b9a\u3059\u308b\u65b9\u6cd5\u3068\u2461\u5168\u304f\u306a\u306b\u3082\u306a\u3044listView\u306b\u5bfe\u3057\u753b\u50cf\u3092\u30c9\u30ed\u30c3\u30d7\u3059\u308b\u6642\u3001\u201cInsert\u201d\u304c\u4f7f\u3048\u306a\u304b\u3063\u305f\u3053\u3068\u3067\u3059\u3002<br \/>\n<span style=\"font-size: 14pt;\">\u3000\u2460\u306b\u5bfe\u3057\u3066\u306f\u30d7\u30ed\u30d1\u30c6\u30a3\u60c5\u5831\u3067\u53d6\u5f97\u3067\u304d\u3001\u2461\u306f\u30bf\u30fc\u30b2\u30c3\u30c8\u306e listView\u306e\u9805\u76ee\u6570\u306b\u3088\u3063\u3066\u3001\u201cAdd\u201d \u3068 \u201cInsert\u201d\u3092\u4f7f\u3044\u5206\u3051\u308b\u69d8\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002<\/span><\/span><\/p>\n<pre class=\"height-set:true lang:c# decode:true\" title=\"ListViewTest.sln DragAndDrop_FromListviewToListview\">using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\n\r\nusing System.IO;\r\n\r\nnamespace ListViewTest\r\n{\r\n    public partial class Form4 : Form\r\n    {\r\n        private string img_dir;\r\n\r\n        public Form4()\r\n        {\r\n            InitializeComponent();\r\n        }\r\n\r\n        private void Form4_Load(object sender, EventArgs e)\r\n        {\r\n            img_dir = @\"\"; \/\/ \u753b\u50cf\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\r\n\r\n            listView1_init();\r\n            get_pic_thumbnail(1);\r\n            chk_listView1(0);\r\n            chk_listView2(0);\r\n        }\r\n\r\n        private void listView1_init()\r\n        {\r\n            listView1.Items.Clear();\r\n            listView2.Items.Clear();\r\n\r\n            imageList1.Images.Clear();\r\n\r\n\r\n            listView1.LargeImageList = imageList1;\r\n            listView1.AllowDrop = true;\r\n            listView1.MultiSelect = true;\r\n\r\n            listView2.LargeImageList = imageList1;\r\n            listView2.AllowDrop = true;\r\n            listView2.MultiSelect = true;\r\n\r\n            listView1.ItemDrag += new ItemDragEventHandler(listView1_ItemDrag);\r\n            listView1.DragOver += new DragEventHandler(listView1_DragOver);\r\n            listView1.DragDrop += new DragEventHandler(listView1_DragDrop);\r\n\r\n            listView2.ItemDrag += new ItemDragEventHandler(listView2_ItemDrag);\r\n            listView2.DragOver += new DragEventHandler(listView2_DragOver);\r\n            listView2.DragDrop += new DragEventHandler(listView2_DragDrop);\r\n\r\n        }\r\n\r\n\r\n        \/\/ 1-\u2460\u30c9\u30e9\u30c3\u30b0\u6642\uff11\u56de\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\r\n        private void listView1_ItemDrag(Object sender, ItemDragEventArgs e)\r\n        {\r\n            listView1.DoDragDrop((ListViewItem)e.Item, DragDropEffects.Copy | DragDropEffects.Move);\r\n        }\r\n\r\n\r\n        \/\/ 1-\u2461\u30a2\u30a4\u30c6\u30e0\u30c9\u30e9\u30c3\u30b0\u4e2d\u306b\u7e70\u308a\u8fd4\u3057\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\r\n        private void listView1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)\r\n        {\r\n            if (e.Data.GetDataPresent(typeof(ListViewItem)))\r\n            {\r\n                if ((e.KeyState &amp; 0x1) &gt; 0 &amp;&amp; (e.KeyState &amp; 0x8) &gt; 0)\r\n                {   \r\n                    e.Effect = DragDropEffects.Copy;\r\n                }\r\n                else\r\n                {\r\n                    e.Effect = DragDropEffects.Move;\r\n                }\r\n\r\n                Point targetPoint = listView1.PointToClient(new Point(e.X, e.Y));\r\n\r\n                int targetIndex = listView1.InsertionMark.NearestIndex(targetPoint);\r\n                int ins_p_Index = targetIndex;                              \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n\r\n                \/\/ \u6700\u8fd1\u30a2\u30a4\u30c6\u30e0\u304c\u3001\u73fe\u30c9\u30e9\u30c3\u30b0\u9805\u76ee\uff08\u81ea\u5206\u81ea\u8eab\uff09\u306e\u5834\u5408\u306f\u3001-1 \u304c\u8fd4\u3055\u308c\u308b\u3002\r\n                if (targetIndex &gt; -1)\r\n                {\r\n                    Rectangle itemBounds = listView1.GetItemRect(targetIndex);\r\n                    if (targetPoint.X &gt; itemBounds.Left + (itemBounds.Width \/ 2))\r\n                    {\r\n                        listView1.InsertionMark.AppearsAfterItem = true;    \/\/ \u8fd1\u3044\u30a2\u30a4\u30c6\u30e0\u5f8c\u65b9\r\n                        ins_p_Index++;                                      \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n                    }\r\n                    else\r\n                    {\r\n                        listView1.InsertionMark.AppearsAfterItem = false;   \/\/ \u8fd1\u3044\u30a2\u30a4\u30c6\u30e0\u524d\u65b9\r\n                    }\r\n                }\r\n\r\n                listView1.InsertionMark.Index = targetIndex;\r\n            }\r\n        }\r\n\r\n        \/\/ 1-\u2462\u30c9\u30ed\u30c3\u30d7\u6642\uff11\u56de\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\r\n        private void listView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)\r\n        {\r\n            if (e.Data.GetDataPresent(typeof(ListViewItem)))\r\n            {\r\n                Point targetPoint = listView1.PointToClient(new Point(e.X, e.Y));\r\n                int targetIndex = listView1.InsertionMark.NearestIndex(targetPoint);                \/\/ \u8fd1\u3044\u4f4d\u7f6e\r\n                int ins_p_Index = targetIndex;                                                      \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n\r\n                ListViewItem srcItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));\r\n\r\n                \/\/ \u633f\u5165\u5148\u306e\u753b\u50cf\u30a2\u30a4\u30c6\u30e0\u304c\u30bc\u30ed\u306e\u5834\u5408\u3092\u8003\u616e\r\n                if (targetIndex &gt; -1 || (targetIndex == -1 &amp;&amp; listView1.Items.Count == 0))\r\n                {\r\n                    if (targetIndex &gt; -1)\r\n                    {   \/\/ \u30de\u30a6\u30b9\u30ab\u30fc\u30bd\u30eb\u306e\u53f3\u30fb\u5de6\u306b\u3088\u3063\u3066\u4fee\u6b63\r\n                        Rectangle itemBounds = listView1.GetItemRect(targetIndex);\r\n                        if (targetPoint.X &gt; itemBounds.Left + (itemBounds.Width \/ 2))\r\n                        {\r\n                            ins_p_Index++;                                                              \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n                        }\r\n                    }\r\n\r\n                    int item_cnt = srcItem.ListView.SelectedItems.Count;                                   \/\/ \u9078\u629e\u753b\u50cf\u6570\r\n\r\n                    if (item_cnt &gt; 0)\r\n                    {\r\n                        ListViewItem[] item_selected = new ListViewItem[srcItem.ListView.SelectedItems.Count];\r\n\r\n                        \/\/ \u9078\u629e\u9805\u76ee\u3092\u4e00\u65e6\u914d\u5217\u306b\u683c\u7d0d\r\n                        for (int i = 0; i &lt; srcItem.ListView.SelectedItems.Count; i++)\r\n                        {   item_selected[i] = srcItem.ListView.SelectedItems[i]; }\r\n\r\n                        \/\/ \u914d\u5217\u306b\u683c\u7d0d\u3057\u305f\u9078\u629e\u9805\u76ee\u3092\u9806\u756a\u306b\u8ffd\u52a0\r\n                        for (int i = 0; i &lt; item_selected.Length; i++)\r\n                        {\r\n                            int exec_order = item_selected.Length - i - 1;          \/\/ \u8ffd\u52a0\u9806\u756a\u3092\u9006\u8ee2\u3057\u633f\u5165\u3059\u308b\r\n\r\n                            if (ins_p_Index == -1)\r\n                            {\r\n                                listView1.Items.Add(item_selected[exec_order].Text, item_selected[exec_order].ImageIndex);\r\n                                ins_p_Index = 0;\r\n                            }\r\n                            else\r\n                            {\r\n                                listView1.Items.Insert(ins_p_Index, item_selected[exec_order].Text, item_selected[exec_order].ImageIndex);\r\n                            }\r\n                        }\r\n\r\n                        \/\/ \u79fb\u52d5\uff08Move\uff09\u6642\u30bd\u30fc\u30b9\u30a2\u30a4\u30c6\u30e0\u524a\u9664\r\n                        if ((e.KeyState &amp; 0x8) &lt;= 0)\r\n                        {\r\n                            for (int i = 0; i &lt; item_selected.Length; i++)\r\n                            {\r\n                                if (item_selected[i] != null)\r\n                                {\r\n                                    item_selected[i].ListView.Items.Remove(item_selected[i]);\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n\r\n                    chk_listView1(1);                                                               \/\/ \u518d\u63cf\u753b  \r\n                    chk_listView2(1);\r\n                }\r\n            }\r\n        }\r\n\r\n\r\n        \/\/ 1-\u2460\u30c9\u30e9\u30c3\u30b0\u6642\uff11\u56de\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\r\n        private void listView2_ItemDrag(Object sender, ItemDragEventArgs e)\r\n        {\r\n            listView2.DoDragDrop((ListViewItem)e.Item, DragDropEffects.Copy | DragDropEffects.Move);\r\n        }\r\n\r\n        \/\/ 2-\u2461\u30a2\u30a4\u30c6\u30e0\u30c9\u30e9\u30c3\u30b0\u4e2d\u306b\u7e70\u308a\u8fd4\u3057\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\r\n        private void listView2_DragOver(object sender, System.Windows.Forms.DragEventArgs e)\r\n        {\r\n            if (e.Data.GetDataPresent(typeof(ListViewItem)))\r\n            {\r\n                if ((e.KeyState &amp; 0x1) &gt; 0 &amp;&amp; (e.KeyState &amp; 0x8) &gt; 0)\r\n                {   \r\n                    e.Effect = DragDropEffects.Copy;\r\n                }\r\n                else\r\n                {\r\n                    e.Effect = DragDropEffects.Move;\r\n                }\r\n\r\n                Point targetPoint = listView2.PointToClient(new Point(e.X, e.Y));\r\n\r\n                int targetIndex = listView2.InsertionMark.NearestIndex(targetPoint);\r\n                int ins_p_Index = targetIndex;                              \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n\r\n                \/\/ \u6700\u8fd1\u30a2\u30a4\u30c6\u30e0\u304c\u3001\u73fe\u30c9\u30e9\u30c3\u30b0\u9805\u76ee\uff08\u81ea\u5206\u81ea\u8eab\uff09\u306e\u5834\u5408\u306f\u3001-1 \u304c\u8fd4\u3055\u308c\u308b\u3002\r\n                if (targetIndex &gt; -1)\r\n                {\r\n                    Rectangle itemBounds = listView2.GetItemRect(targetIndex);\r\n                    if (targetPoint.X &gt; itemBounds.Left + (itemBounds.Width \/ 2))\r\n                    {\r\n                        listView2.InsertionMark.AppearsAfterItem = true;    \/\/ \u8fd1\u3044\u30a2\u30a4\u30c6\u30e0\u5f8c\u65b9\r\n                        ins_p_Index++;                                      \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n                    }\r\n                    else\r\n                    {\r\n                        listView2.InsertionMark.AppearsAfterItem = false;   \/\/ \u8fd1\u3044\u30a2\u30a4\u30c6\u30e0\u524d\u65b9\r\n                    }\r\n                }\r\n\r\n                listView2.InsertionMark.Index = targetIndex;\r\n            }\r\n        }\r\n\r\n        \/\/ 2-\u2462\u30c9\u30ed\u30c3\u30d7\u6642\uff11\u56de\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8\r\n        private void listView2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)\r\n        {\r\n            if (e.Data.GetDataPresent(typeof(ListViewItem)))\r\n            {\r\n                Point targetPoint = listView2.PointToClient(new Point(e.X, e.Y));\r\n                int targetIndex = listView2.InsertionMark.NearestIndex(targetPoint);                \/\/ \u8fd1\u3044\u4f4d\u7f6e\r\n                int ins_p_Index = targetIndex;                                                      \/\/ \u4e2d\u9593\u4f4d\u7f6e\r\n\r\n                ListViewItem srcItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));\r\n\r\n                \/\/ \u633f\u5165\u5148\u306e\u753b\u50cf\u30a2\u30a4\u30c6\u30e0\u304c\u30bc\u30ed\u306e\u5834\u5408\u3092\u8003\u616e\r\n                if (targetIndex &gt; -1 || (targetIndex == -1 &amp;&amp; listView2.Items.Count == 0))\r\n                {\r\n                    if (targetIndex &gt; -1)\r\n                    {   \/\/ \u30de\u30a6\u30b9\u30ab\u30fc\u30bd\u30eb\u306e\u53f3\u30fb\u5de6\u306b\u3088\u3063\u3066\u4fee\u6b63\r\n                        Rectangle itemBounds = listView2.GetItemRect(targetIndex);\r\n                        if (targetPoint.X &gt; itemBounds.Left + (itemBounds.Width \/ 2)){ ins_p_Index++; }\r\n                    }\r\n\r\n                    \/\/listBox2.Items.Clear();\r\n                    int item_cnt = srcItem.ListView.SelectedItems.Count;                            \/\/ \u9078\u629e\u753b\u50cf\u6570\r\n\r\n                    if (item_cnt &gt; 0)\r\n                    {\r\n                        ListViewItem[] item_selected = new ListViewItem[srcItem.ListView.SelectedItems.Count];\r\n\r\n                        \/\/ \u9078\u629e\u9805\u76ee\u3092\u4e00\u65e6\u914d\u5217\u306b\u683c\u7d0d\r\n                        for (int i = 0; i &lt; srcItem.ListView.SelectedItems.Count; i++)\r\n                        {   item_selected[i] = srcItem.ListView.SelectedItems[i]; }\r\n\r\n\r\n                        \/\/ \u914d\u5217\u306b\u683c\u7d0d\u3057\u305f\u9078\u629e\u9805\u76ee\u3092\u9806\u756a\u306b\u8ffd\u52a0\r\n                        for (int i = 0; i &lt; item_selected.Length; i++)\r\n                        {\r\n                            int exec_order = item_selected.Length - i - 1;                          \/\/ \u8ffd\u52a0\u9806\u756a\u3092\u9006\u8ee2\u633f\u5165\r\n\r\n                            if (ins_p_Index == -1)\r\n                            {\r\n                                listView2.Items.Add(item_selected[exec_order].Text, item_selected[exec_order].ImageIndex);\r\n                                ins_p_Index = 0 ;\r\n                            }\r\n                            else \r\n                            {\r\n                                listView2.Items.Insert(ins_p_Index, item_selected[exec_order].Text, item_selected[exec_order].ImageIndex);\r\n                            }\r\n    \r\n                        }\r\n\r\n                        \/\/ \u79fb\u52d5\uff08Move\uff09\u6642\u30bd\u30fc\u30b9\u30a2\u30a4\u30c6\u30e0\u524a\u9664\r\n                        if ((e.KeyState &amp; 0x8) &lt;= 0)\r\n                        {\r\n                            for (int i = 0; i &lt; item_selected.Length; i++)\r\n                            {\r\n                                if (item_selected[i] != null)\r\n                                {\r\n                                    item_selected[i].ListView.Items.Remove(item_selected[i]);\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n\r\n                    chk_listView1(1);                                                               \/\/ \u518d\u63cf\u753b  \r\n                    chk_listView2(1);\r\n\r\n                }\r\n            }\r\n        }\r\n\r\n\r\n        \/\/ \u30b5\u30e0\u30cd\u30a4\u30eb\u753b\u50cf\u53d6\u5f97\u30fblistView\u8868\u793a\r\n        private void get_pic_thumbnail(int kbn)\r\n        {\r\n            string[] jpgFiles = System.IO.Directory.GetFiles(img_dir, \"*.PNG\");\r\n\r\n            int width = 80;\r\n            int height = 80;\r\n\r\n            imageList1.ImageSize = new Size(width, height);\r\n\r\n            \/\/ imageList , listView \u767b\u9332\r\n            for (int i = 0; i &lt; jpgFiles.Length; i++)\r\n            {\r\n                String F_Name = Path.GetFileName(jpgFiles[i]);\r\n                Image original = Bitmap.FromFile(jpgFiles[i]);\r\n                Image thumbnail = createThumbnail(original, width, height);\r\n\r\n                imageList1.Images.Add(F_Name, thumbnail);\r\n\r\n                \/\/imageList1.Images.Add(thumbnail);\r\n\r\n                if (kbn == 1) { listView1.Items.Add(F_Name, i); }\r\n                else if (kbn == 2) { listView2.Items.Add(F_Name, i); }\r\n                else { \r\n                    listView1.Items.Add(F_Name, i);\r\n                    listView2.Items.Add(F_Name, i);\r\n                }          \r\n\r\n                original.Dispose();\r\n                thumbnail.Dispose();\r\n            }\r\n        }\r\n\r\n\r\n        \/\/ \u5e45w\u3001\u9ad8\u3055h \u30b5\u30e0\u30cd\u30a4\u30eb\u753b\u50cf\u4f5c\u6210\r\n        Image createThumbnail(Image image, int w, int h)\r\n        {\r\n            Bitmap canvas = new Bitmap(w, h);\r\n\r\n            Graphics g = Graphics.FromImage(canvas);\r\n            g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);\r\n\r\n            float fw = (float)w \/ (float)image.Width;\r\n            float fh = (float)h \/ (float)image.Height;\r\n\r\n            float scale = Math.Min(fw, fh);\r\n            fw = image.Width * scale;\r\n            fh = image.Height * scale;\r\n\r\n            g.DrawImage(image, (w - fw) \/ 2, (h - fh) \/ 2, fw, fh);\r\n            g.Dispose();\r\n\r\n            return canvas;\r\n        }\r\n\r\n\r\n        \/\/ \u30a2\u30a4\u30c6\u30e0\u306e\u95a2\u9023\u30d7\u30ed\u30d1\u30c6\u30a3\u53d6\u5f97\u30fb\u518d\u8868\u793a\r\n        private void chk_listView1(int kbn)\r\n        {\r\n            \/\/listBox1.Items.Clear();\r\n            \/\/ \u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\uff11(listView1)\u30d7\u30ed\u30d1\u30c6\u30a3\r\n            int listViewCnt1 = listView1.Items.Count;\r\n            string[,] dat_vw1 = new string[listViewCnt1, 4];\r\n            for (int i = 0; i &lt; listViewCnt1; i++)\r\n            {\r\n                dat_vw1[i, 0] = listView1.Items[i].Index.ToString();\r\n                dat_vw1[i, 1] = listView1.Items[i].Text;\r\n                dat_vw1[i, 2] = listView1.Items[i].ImageIndex.ToString();\r\n                dat_vw1[i, 3] = listView1.Items[i].ImageKey;\r\n\r\n                \/\/listBox1.Items.Add(dat_vw1[i, 0] + \"  ,  \" + dat_vw1[i, 1] + \"  ,  \" + dat_vw1[i, 2] + \"  ,  \" + dat_vw1[i, 3]);\r\n            }\r\n\r\n            \/\/ listView\u3092\u4e00\u65e6\u521d\u671f\u5316\u3057\u518d\u8868\u793a\u3059\u308b\r\n            if (kbn == 1)\r\n            {\r\n                listView1.Clear();\r\n\r\n                for (int i = 0; i &lt; dat_vw1.GetLength(0); i++)\r\n                {\r\n                    listView1.Items.Add(dat_vw1[i, 1], int.Parse(dat_vw1[i, 2]));\r\n                }\r\n            }\r\n        }\r\n\r\n        \/\/ \u30a2\u30a4\u30c6\u30e0\u306e\u95a2\u9023\u30d7\u30ed\u30d1\u30c6\u30a3\u53d6\u5f97\u30fb\u518d\u8868\u793a\r\n        private void chk_listView2(int kbn)\r\n        {\r\n            \/\/listBox1.Items.Clear();\r\n            \/\/ \u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\uff11(listView1)\u30d7\u30ed\u30d1\u30c6\u30a3\r\n            int listViewCnt2 = listView2.Items.Count;\r\n            string[,] dat_vw1 = new string[listViewCnt2, 4];\r\n            for (int i = 0; i &lt; listViewCnt2; i++)\r\n            {\r\n                dat_vw1[i, 0] = listView2.Items[i].Index.ToString();\r\n                dat_vw1[i, 1] = listView2.Items[i].Text;\r\n                dat_vw1[i, 2] = listView2.Items[i].ImageIndex.ToString();\r\n                dat_vw1[i, 3] = listView2.Items[i].ImageKey;\r\n\r\n                \/\/listBox1.Items.Add(dat_vw1[i, 0] + \"  ,  \" + dat_vw1[i, 1] + \"  ,  \" + dat_vw1[i, 2] + \"  ,  \" + dat_vw1[i, 3]);\r\n            }\r\n\r\n            \/\/ listView\u3092\u4e00\u65e6\u521d\u671f\u5316\u3057\u518d\u8868\u793a\u3059\u308b\r\n            if (kbn == 1)\r\n            {\r\n                listView2.Clear();\r\n\r\n                for (int i = 0; i &lt; dat_vw1.GetLength(0); i++)\r\n                {\r\n                    listView2.Items.Add(dat_vw1[i, 1], int.Parse(dat_vw1[i, 2]));\r\n                }\r\n            }\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            listView1.Items.Clear();\r\n            listView2.Items.Clear();\r\n            imageList1.Images.Clear();\r\n            get_pic_thumbnail(2);\r\n            chk_listView1(0);\r\n            chk_listView2(0);\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            listView1.Items.Clear();\r\n            listView2.Items.Clear();\r\n            imageList1.Images.Clear();\r\n            get_pic_thumbnail(1);\r\n            chk_listView1(0);\r\n            chk_listView2(0);\r\n        }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2.63291%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff; width: 96.2025%;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">\u5b9f\u969b\u306e\u5199\u771f\u3067\u306e\u51e6\u7406<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-size: 14pt;\">\u3000listView\u9593\u306e\u753b\u50cf\u306e\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u306f\u5199\u771f\u306e\u7de8\u96c6\uff08\u4e26\u3073\u66ff\u3048\uff09\u3092\u60f3\u5b9a\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u4f5c\u6210\u4e2d\u306f\u3001\u78ba\u5b9f\u306b\u4e26\u3073\u66ff\u3048\u304c\u51fa\u6765\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b\u76ee\u7684\u3067\u756a\u53f7\u306e\u66f8\u3044\u3066\u3042\u308b\u753b\u50cf\u3092\u7528\u3044\u307e\u3057\u305f\u304c\u3001\u6700\u5f8c\u306b\u5b9f\u969b\u306b\u64ae\u5f71\u3057\u305f\u5199\u771f\u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002\u30b5\u30e0\u30cd\u30a4\u30eb\u753b\u50cf\u306b\u5909\u63db\u3059\u308b\u524d\u306f\u3001\u7d04\uff12\uff5e\uff17Mbyte\u7a0b\u5ea6\u3042\u308b\u5199\u771f\u3067\u3059\u3002<br \/>\n<span style=\"font-size: 14pt;\">\u3000\u4e0b\u56f3\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u8d77\u52d5\u5f8c\u3001\uff13\u3064\u5199\u771f\u9078\u629e\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/span><span style=\"font-size: 14pt;\"><br \/>\n<\/span><img loading=\"lazy\" class=\"aligncenter size-full wp-image-3138\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/101-2.png\" alt=\"\" width=\"1017\" height=\"636\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/101-2.png 1017w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/101-2-300x188.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/101-2-768x480.png 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><br \/>\n<span style=\"font-size: 14pt;\">\u3000\u9078\u3093\u3060\uff13\u5199\u771f\u3092\u79fb\u52d5\u3057\u307e\u3057\u305f\u3002<\/span><br \/>\n<img loading=\"lazy\" class=\"aligncenter size-full wp-image-3139\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/102-2.png\" alt=\"\" width=\"1017\" height=\"636\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/102-2.png 1017w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/102-2-300x188.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/102-2-768x480.png 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><br \/>\n<span style=\"font-size: 14pt;\">\u3000\u66f4\u306b\uff12\u5199\u771f\u3092\u30b3\u30d4\u30fc\u3057\u3066\u3044\u307e\u3059\u3002<\/span><br \/>\n<img loading=\"lazy\" class=\"aligncenter size-full wp-image-3140\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/103-2.png\" alt=\"\" width=\"1017\" height=\"636\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/103-2.png 1017w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/103-2-300x188.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/02\/103-2-768x480.png 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><\/p>\n<p>&nbsp;<\/p>\n<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2.63291%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff; width: 96.2025%;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">\u307e\u3068\u3081<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-size: 14pt;\">\u3000\u3068\u308a\u3042\u3048\u305a\u3001listView \u3092\u4f7f\u3063\u3066\u3001\u3084\u308a\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u305f\u3053\u3068\u306f\u5b9f\u73fe\u51fa\u6765\u307e\u3057\u305f\u3002\u6b21\u56de\u4ee5\u964d\u306f\u540c\u3058\u304fC#\u3067\u63cf\u753b\u51e6\u7406\u3092\u691c\u8a0e\u3057\u3066\u3044\u304f\u3064\u3082\u308a\u3067\u3059\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>listView\u9593\u306e\u753b\u50cf\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u00a0 \u3000C# listView\u95a2\u4fc2\u306e\u307e\u3068\u3081\u3068\u3057\u3066\u3001\u540c\u3058 listView\u5185\u3060\u3051\u3067\u306a\u304f\u3001\u7570\u306a\u308b listView\u9593\u306e\u753b\u50cf\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u304c\u51fa\u6765\u308b\u69d8\u306b\u691c\u8a0e\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u4e0b\u56f3\u306f\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u8d77\u52d5 &hellip; <a href=\"https:\/\/kats-eye.net\/info\/2020\/02\/14\/c-list%e2%80%90image-04\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">C# ListView\u9593\u306e\u30de\u30a6\u30b9D&#038;D\u306b\u3088\u308b\u5199\u771f\u306e\u79fb\u52d5\u3068\u30b3\u30d4\u30fc<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3140,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75],"tags":[80,82,81],"_links":{"self":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/3122"}],"collection":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/comments?post=3122"}],"version-history":[{"count":16,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/3122\/revisions"}],"predecessor-version":[{"id":3145,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/3122\/revisions\/3145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media\/3140"}],"wp:attachment":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media?parent=3122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/categories?post=3122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/tags?post=3122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}