我在做什么错在这里?要温柔。CheckedListBox和EventArgs的
对于CheckedListBox
,我可以简单地通过更新项目:
private void button3_Click(object sender, EventArgs e)
{
checkedListBox4.Items.Add("whatever"); //or use an object
}
的伟大工程,但我想要做的是从方法的另一个类
左右的时间内发送CheckedListItem
一组项目,我建立了另一个class something:form1
,它有一个委托,指向我称为\调用的方法
委托调用\调用这种方式:
public delegate void m_del(List<DirectoryInfo> ww, string rr);
其他地方的代码:
m_del methtouse = new m_del(listme)
public void listme(List<DirectoryInfo> fi, string mypath)
{
foreach (DirectoryInfo j in fi)
{
mypath = null; //mypath used by another method
try
{
NewCheckboxListItem cb1 = new NewCheckboxListItem();
cb1.Tag = j.Name;
cb1.Text = j.Name;
checkedListBox4.Items.Add(cb1);
}
catch (Exception w)
{
MessageBox.Show(w.Message);
}
}
}
public class NewCheckboxListItem
{
// define a text and
// a tag value
public string Text;
public string Tag;
// override ToString(); this
// is what the checkbox control
// displays as text
public override string ToString()
{
return this.Text;
}
}
methtouse(a List<DirectoryInfo> ww, a string rr)
{}
会发生什么是项目集合中的checkedListBox4
被更新,并有尽可能多的价值,因为我把它,但它不会绘制项目\显示项目
我试图调用checkedListBox4_datavaluememberchanged
方法和其他一些checkedListBox4_changed
事件,但再次集合中的项目被更新,但它们不会出现在CheckedListBox
我认为它是与没有eventargs
它有一个简单的方式通过所有的属性,事件,一个成功的CheckedListBox
与不成功CheckedListBox
的性能方面做对比的一侧(编程)
注:类从form1
其中CheckedListBox
位于继承和方法访问权限设置为公开。
添加 “this.Show()” 的方法的底部。你现在看到了吗? – 2009-07-26 18:03:01