最佳答案
您可以使用 Substring()
提取所需的值。
如果你想要前 3 个字符,你可以这样做:
string.Substring(0,3);
如果要更改项目的文本,在选择项目后,您必须使用 ComboBox
的事件:
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox.SelectedIndex > -1)
{
string s = comboBox.GetItemText(this.comboBox.SelectedItem).Substring(0, 3);
this.BeginInvoke((MethodInvoker)delegate { this.comboBox1.Text = s; });
}
}
关于c# - 在组合框中选择项目后更改文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42853284/