【发布时间】:2015-05-13 23:42:59
【问题描述】:
您好,我正在尝试将 this 库的输出收集到列表框中。
这是来自测试项目的部分代码,我已尝试修改:
public partial class Form1 : Form
{
D.Net.Clipboard.ClipboardManager Manager;
public Form1()
{
InitializeComponent();
Manager = new D.Net.Clipboard.ClipboardManager(this);
Manager.Type = D.Net.Clipboard.ClipboardManager.CheckType.Text;
Manager.OnNewTextFound += (sender, eventArg) =>
{
button1.Text = eventArg; //just testing, working correctly
listBox1.Items.Add(eventArg); //does not show neither result nor any error
MessageBox.Show(String.Format("New text found in clipboard : {0}", eventArg));
};
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("test"); //working correctly
}
}
问题是当我尝试将项目添加到列表中时它什么也不做,并且进一步的代码行(在此函数中)根本不运行。
我尝试通过一些自定义类和不同的表达式来修复它,但对我没有任何帮助(是的,我是菜鸟)。也尝试用 textBox 来做,结果是一样的,但是按钮上的文本会改变。
看起来完全是蹩脚的问题,但我已经花了将近 5 个小时通过谷歌搜索、阅读微软文档、SO,我能得到的最接近的是 this,因为我可以看到那里建议的东西已经实现。
【问题讨论】:
-
尝试使用
listBox1.Items.Add(eventArg.ToString());看看是否可行。 -
button1.Text = eventArg;甚至不会为我编译。 -
@Grant Winney 是的,工作应该@dub stylee,不,它没有