2008-12-29 49 views

回答

1

它工作得很好,當我試圖驗證碼:

public partial class Form1 : Form { 
    MyListBox mList; 
    public Form1() { 
     InitializeComponent(); 
    } 

    protected override void OnLoad(EventArgs e) { 
     mList = new MyListBox(this); 
     mList.Location = new Point(5, 10); 
     mList.Size = new Size(50, this.ClientSize.Height + 50); 
     for (int ix = 0; ix < 100; ++ix) mList.Items.Add(ix); 
     mList.SelectedIndexChanged += new EventHandler(mList_SelectedIndexChanged); 
    } 

    void mList_SelectedIndexChanged(object sender, EventArgs e) { 
     MessageBox.Show(mList.SelectedIndex.ToString()); 
    } 

    protected override void Dispose(bool disposing) { 
     // Moved from Designer.cs file 
     if (disposing) mList.Dispose(); 
     if (disposing && (components != null)) { 
     components.Dispose(); 
     } 
     base.Dispose(disposing); 
    } 

    } 
+0

難道是因爲我已經刪除了設置的CreateParams風格(否則我看不到列表框中的話)的線?它需要什麼? – 2008-12-30 11:33:28

相關問題