c#combobox中有三个值“112”“113”“114”,选中第一个时,显示为2,选中第二个时显示为3。怎么解决

来源:百度知道 编辑:UC知道 时间:2024/05/22 03:36:37
虽然我能成功截取最后一个字符,可页面下拉的值仍然是112,或113

那你选择第三个时,报数组越界吗?

可能是你的index写错吧

是要选114实际上是4么?
如果是 那么就处理字符串

char [] a =combobox.Text.toCharArry();

a[2];就是你要的了

读取值,截取字符串不就行了。用SubString();。你试试看看。

string tempstr = "";
tempstr = comboBox1.Text;
tempstr = tempstr.Substring(tempstr.Length - 1, 1);