2009-07-26 41 views
0

我在做什麼錯在這裏?要溫柔。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位於繼承和方法訪問權限設置爲公開。

+1

添加 「this.Show()」 的方法的底部。你現在看到了嗎? – 2009-07-26 18:03:01

回答