你好,
我正在做的是一种显示来自特定文件夹的图像的方法,但是当我调试时,我在最后一行代码中遇到了这个错误,我不知道为什么。**
Error 3 'MBKiosk.classTools' does not contain a definition for 'Controls' and no extension
method 'Controls' accepting a first argument of type 'MBKiosk.classTools' could be found (are you
missing a using directive or an assembly reference?)
谢谢你的帮助。
这是代码:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.Collections.ObjectModel;
using MBKiosk;
namespace MBKiosk
{
class classTools
{
public void ShowImages(string path)
{
FlowLayoutPanel imagePanel = new FlowLayoutPanel();
imagPanel.FlowDirection = FlowDirection.LeftToRight;
imagePanel.Size = new Size(1240, 630);
imagePanel.Location = new Point(12, 344);
imagePanel.WrapContents = true;
imagePanel.AutoScroll = false;
DirectoryInfo dInfo = new DirectoryInfo(path);
foreach (FileInfo file in dInfo.GetFiles())
{
System.Diagnostics.Debug.Print(file.Extension);
if ((file.Extension == ".jpg") || (file.Extension == ".gif") || (file.Extension ==
".png"))
{
PictureBox image = new PictureBox();
image.Image = Image.FromFile(file.FullName);
image.SizeMode = PictureBoxSizeMode.Normal;
image.Size = new Size(180, 108);
imagePanel.Controls.Add(image);
imagePanel.Refresh();
}
}
this.Controls.Add(imagePanel);
}
}
}