2011-04-03 78 views
0

目前我有一個comboBox從Outlook中讀取信息,並將列表存儲爲可供comboBox選擇的值。從組合框中檢索項目

我想能夠將按鈕的文本設置爲存儲在此組合框中的值。

我有一個按鈕陣列,用於存儲要更改的按鈕。下面是代碼,這樣一旦點擊,來自comboBox的值將顯示爲按鈕中的文本標籤,是我卡住的地方。

private void Mmaptsks_Click(object sender, EventArgs e) 
    {    
     int count = cmb.Items.Count; 

     for (int i = 0; i < count; i++) 
     { 
      buttonArray[i].Visible = true; 
      buttonArray[i].Text = ??; 

     } 
    } 

感謝,

湯姆

回答

0

你可以試試:

buttonArray[i].Text = cmb.Items[i].ToString(); 

或者,如果你的組合項目不是字符串,那麼你可以:

buttonArray[i].Text = (cmb.Items[i] as YourType).SomeProperty;