[英]Change text value after item is selected in Combobox
您可以使用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; });
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.