从组合框中检索项目

时间:2011-04-03 20:19:37

标签: c#

目前我有一个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 = ??;

        }
    }

谢谢,

汤姆

1 个答案:

答案 0 :(得分:0)

您可以尝试:

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

或者,如果你的组合项目不是字符串,那么你可以:

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