You can extract the desired value using Substring()
. If you want the first 3 characters you can do it like this:
string.Substring(0,3);
If you want to change the text of the item, after it is selected, you will have to use an event of the 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; });
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.