gpt4 book ai didi

c# - 如何更改 ComboBox 项目的文本?

转载 作者:太空狗 更新时间:2023-10-29 22:34:02 28 4
gpt4 key购买 nike

我有一个组合框,其中包含 dataGridView 列的名称,我可以将组合框中显示的项目的文本更改为我想要的任何文本吗?

for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
if (dataGridView1.Columns[i].ValueType == typeof(string) &&
i != 6 &&
i != 7 &&
i != 8 &&
i != 9)
comboBox1.Items.Add(dataGridView1.Columns[i].Name);
}
comboBox1.SelectedIndex = 0;

最佳答案

希望对你有帮助

combobox.Items[combobox.FindStringExact("string value")] = "new string value";

FindStringExact 方法返回特定项目文本的索引,因此这是更改 Combobox 项目文本的更好方法。

注意:这在 C# 上运行良好。

关于c# - 如何更改 ComboBox 项目的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7030542/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com