如何实现包含带有样式的图像的ListView
因此,我一直在使用一个应用程序,我需要将缩略图显示为干净并以良好的方式使用空间。
Style A 是我迄今为止的作品。 我想要实现的是类似风格 B 的效果。没有标题,并以良好的方式利用空间。我需要这方面的帮助。网上没有教程。 ListView可以做这样的事情吗?或者我应该制作图片框并将它们放在滚动视图中?
代码:
private void button1_Click(object sender, EventArgs e)
{
ImageList myImageList = new ImageList();
myImageList.ImageSize = new Size(48, 48);
DirectoryInfo dir = new DirectoryInfo(@"C:\img");
foreach (FileInfo file in dir.GetFiles())
{
try
{
myImageList.Images.Add(Image.FromFile(file.FullName));
}
catch
{
Console.WriteLine("This is not an image file");
}
}
myListView.LargeImageList = myImageList;
myListView.Items.Add("a", 0);
myListView.Items.Add("b", 1);
myListView.Items.Add("c", 2);
So I have been working with an app where I need to show the thumbnails as clean and use the space in a good way.
Style A is my work until now.
What I want to accomplish is something like style B. no titles and use the space in a good way. I need help with this. there was no tutorial on the net. Is ListView able to do such a thing? or shall I make picturesboxes and put them in a scrollview?
the code:
private void button1_Click(object sender, EventArgs e)
{
ImageList myImageList = new ImageList();
myImageList.ImageSize = new Size(48, 48);
DirectoryInfo dir = new DirectoryInfo(@"C:\img");
foreach (FileInfo file in dir.GetFiles())
{
try
{
myImageList.Images.Add(Image.FromFile(file.FullName));
}
catch
{
Console.WriteLine("This is not an image file");
}
}
myListView.LargeImageList = myImageList;
myListView.Items.Add("a", 0);
myListView.Items.Add("b", 1);
myListView.Items.Add("c", 2);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否特别限制使用 Winforms 还是可以使用 WPF?这将使创建变得非常容易。
Are you specifically limited to using Winforms or can you use WPF? It'll make creating that quite easy.