質問するログイン新規登録

質問編集履歴

3

コードを追加しました

2018/04/02 04:46

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -105,4 +105,116 @@
105
105
  }
106
106
  }
107
107
 
108
+ ```
109
+ ```C#
110
+ namespace Page_Switch
111
+ {
112
+ partial class FolderDialog
113
+ {
114
+ /// <summary>
115
+ /// 必要なデザイナー変数です。
116
+ /// </summary>
117
+ private System.ComponentModel.IContainer components = null;
118
+
119
+ /// <summary>
120
+ /// 使用中のリソースをすべてクリーンアップします。
121
+ /// </summary>
122
+ /// <param name="disposing">マネージ リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
123
+ protected override void Dispose(bool disposing)
124
+ {
125
+ if (disposing && (components != null))
126
+ {
127
+ components.Dispose();
128
+ }
129
+ base.Dispose(disposing);
130
+ }
131
+
132
+ #region コンポーネント デザイナーで生成されたコード
133
+
134
+ /// <summary>
135
+ /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
136
+ /// コード エディターで変更しないでください。
137
+ /// </summary>
138
+ private void InitializeComponent()
139
+ {
140
+ this.components = new System.ComponentModel.Container();
141
+ System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("");
142
+ System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("");
143
+ System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("");
144
+ System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("");
145
+ System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("");
146
+ System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("");
147
+ System.Windows.Forms.ListViewItem listViewItem7 = new System.Windows.Forms.ListViewItem("");
148
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FolderDialog));
149
+ this.SelectFolderBtn = new System.Windows.Forms.Button();
150
+ this.FolderView = new System.Windows.Forms.ListView();
151
+ this.ImageList = new System.Windows.Forms.ImageList(this.components);
152
+ this.SuspendLayout();
153
+ //
154
+ // SelectFolderBtn
155
+ //
156
+ this.SelectFolderBtn.Location = new System.Drawing.Point(21, 16);
157
+ this.SelectFolderBtn.Name = "SelectFolderBtn";
158
+ this.SelectFolderBtn.Size = new System.Drawing.Size(89, 32);
159
+ this.SelectFolderBtn.TabIndex = 0;
160
+ this.SelectFolderBtn.Text = "フォルダ選択";
161
+ this.SelectFolderBtn.UseVisualStyleBackColor = true;
162
+ this.SelectFolderBtn.Click += new System.EventHandler(this.SelectFolderBtn_Click);
163
+ //
164
+ // FolderView
165
+ //
166
+ this.FolderView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
167
+ | System.Windows.Forms.AnchorStyles.Left)
168
+ | System.Windows.Forms.AnchorStyles.Right)));
169
+ this.FolderView.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
170
+ listViewItem1,
171
+ listViewItem2,
172
+ listViewItem3,
173
+ listViewItem4,
174
+ listViewItem5,
175
+ listViewItem6,
176
+ listViewItem7});
177
+ this.FolderView.LargeImageList = this.ImageList;
178
+ this.FolderView.Location = new System.Drawing.Point(21, 67);
179
+ this.FolderView.Name = "FolderView";
180
+ this.FolderView.Size = new System.Drawing.Size(620, 285);
181
+ this.FolderView.SmallImageList = this.ImageList;
182
+ this.FolderView.TabIndex = 1;
183
+ this.FolderView.UseCompatibleStateImageBehavior = false;
184
+ //
185
+ // ImageList
186
+ //
187
+ this.ImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ImageList.ImageStream")));
188
+ this.ImageList.TransparentColor = System.Drawing.Color.Transparent;
189
+ this.ImageList.Images.SetKeyName(0, "apple.jpg");
190
+ this.ImageList.Images.SetKeyName(1, "NewYork.jpg");
191
+ this.ImageList.Images.SetKeyName(2, "Hydrangeas.jpg");
192
+ this.ImageList.Images.SetKeyName(3, "Jellyfish.jpg");
193
+ this.ImageList.Images.SetKeyName(4, "Koala.jpg");
194
+ this.ImageList.Images.SetKeyName(5, "Tulips.jpg");
195
+ this.ImageList.Images.SetKeyName(6, "Penguins.jpg");
196
+ this.ImageList.Images.SetKeyName(7, "Chrysanthemum.jpg");
197
+ this.ImageList.Images.SetKeyName(8, "Desert.jpg");
198
+ this.ImageList.Images.SetKeyName(9, "Lighthouse.jpg");
199
+ //
200
+ // FolderDialog
201
+ //
202
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
203
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
204
+ this.Controls.Add(this.FolderView);
205
+ this.Controls.Add(this.SelectFolderBtn);
206
+ this.Name = "FolderDialog";
207
+ this.Size = new System.Drawing.Size(660, 366);
208
+ this.ResumeLayout(false);
209
+
210
+ }
211
+
212
+ #endregion
213
+
214
+ private System.Windows.Forms.Button SelectFolderBtn;
215
+ private System.Windows.Forms.ListView FolderView;
216
+ private System.Windows.Forms.ImageList ImageList;
217
+ }
218
+ }
219
+
108
220
  ```

2

コードの内容をすべて表示しました。

2018/04/02 04:46

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,21 @@
11
11
  よろしくお願いいたします。
12
12
 
13
13
  ```C#
14
+ using System;
15
+ using System.Collections.Generic;
16
+ using System.ComponentModel;
17
+ using System.Drawing;
18
+ using System.Data;
19
+ using System.Linq;
20
+ using System.Text;
21
+ using System.Threading.Tasks;
22
+ using System.Windows.Forms;
23
+ using System.Collections;
24
+ using System.IO;
25
+
26
+ namespace Page_Switch
27
+ {
14
- public partial class FolderDialog : UserControl
28
+ public partial class FolderDialog : UserControl
15
29
  {
16
30
  /// <summary>
17
31
  /// 開いているフォルダ名
@@ -82,10 +96,13 @@
82
96
  //ファイルを列挙する
83
97
  foreach (string f in files)
84
98
  {
85
- FolderView.Items.Add(f);
99
+ FolderView.Items.Add( f , ImageList.Images.Count);
86
- System.Drawing.Image myImage = Image.FromFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + files);
87
- ImageList.Images.Add("myPhoto", myImage);
88
100
  }
89
101
  }
102
+
90
103
  }
104
+
105
+ }
106
+ }
107
+
91
108
  ```

1

内容をもっと詳細にしました。よろしくお願いします。

2018/04/02 04:40

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,9 +1,15 @@
1
1
  windowsフォームアプリケーションの作成で、
2
2
  フォルダを選択するダイアログから指定したフォルダ内のファイルをすべてListViewに表示させるようにしているのですが、
3
3
  実行結果はファイルパス名が表示されるとこまでは行けたのですが。。
4
- 一緒にそのファイルの中にある写真データをサムネイルのような形で表示させたいです。
4
+ 一緒にそのファイルの中にある写真データをサムネイルのように、
5
+ 中身の写真を表示させその写真の下にファイル名を表示させたいのですがどのようにコードを書けばいいのかわかりません。
6
+ ImageListを使って写真を格納してlistviewプロパティから表示させてみたのですが、
7
+ 写真とファイルパスのそれぞれが別々の一覧で表示されてしまいました。
8
+ 例えば、ImageListのコレクションメンバーに写真をダイアログで選択したファイルの画像を動的に格納できたりしませんか?
9
+
5
10
  以下に現在までのコード添付します。
6
11
  よろしくお願いいたします。
12
+
7
13
  ```C#
8
14
  public partial class FolderDialog : UserControl
9
15
  {