【发布时间】:2014-07-23 08:27:21
【问题描述】:
请原谅我问了这么愚蠢的问题。我相信你们中的许多人会发现这很容易,我已经发送了近半天的阅读时间试图弄清楚这一点。
问题来了:
- 我制作了一个 FORM (Form1.cs)。在该表单中,我创建了一个列表视图,并将其命名为“ListView1”。
- 在 Form1.cs 中,我调用了一个名为 FileManager(this) 的函数,并在其中传入了 THIS 对象。
- 在 FileManager.cs 中,我能够 listviewArray= originalForm.Controls.Find("listView1", true) 并找到“listview”。
- 当我执行 listviewArray[0]
文件管理器.cs
FileManager(object sender)
{
if (sender != null)
{
originalForm = (Form)sender;
}
}
public void getFiles()
{
filePaths = Directory.GetFiles(hsocDir);
if(filePaths != null)
{
listviewArray= originalForm.Controls.Find("listView1", true);
if(listviewArray != null)
{
ListViewItem lvi = new ListViewItem("text");
// My Array is listViewArray
// How to add things to Lvi to it.
}
}
== Form1.cs
public Form1()
{
InitializeComponent(`enter code here`);
mysql = new MySQLCheck(this);
fileManager = new FileManager(this);
fileManager.getFiles();
}
【问题讨论】:
标签: c#