1

我真的试图弄清楚为什么 FindStringExact 方法无法在列表中找到字符串。

这是我的代码:

If comboBox.FindStringExact(ds.Tables(0).Rows(0).Item(1).ToString) > 0 Then
   comboBox.SelectedIndex = comboBox.FindStringExact(ds.Tables(0).Rows(0).Item(1).ToString)
End If

有问题的字符串是“000-characters”和“000-characters & characters”,我检查了额外的空格,我的表中的值也是正确的。我在想它与左边的零和中间的 & 号有关。

所有帮助将不胜感激。

4

1 回答 1

0

如果找到搜索值,Findstringexact 将返回索引号..

Dim n as Integer = comboBox.FindStringExact(ds.Tables(0).Rows(0).Item(1).ToString)

If n > -1 Then
   comboBox.SelectedIndex = n
End If

此公式适用于哪个数字单元格的数据网格

于 2013-06-04T07:54:51.737 回答