-3

有人可以解释这种行为吗?

在此处输入图像描述


不仅MouseOver突出显示多个项目(不打算),而且当我Select项目时(鼠标悬停)代码转到 Selection_Changed 事件,该事件会更改其右侧的图片(按预期)但在加载图片时,出现错误出现消息,指出路径中有无效字符。


BD.Shape xShape = new BD.Shape();
comboBoxShapes.ItemsSource = xShape.GetListOfShapes();

 public List<String> GetListOfShapes()
    {
        List<String> iList = new List<String>();
        try
        {
            GetConnectionString iGet = new GetConnectionString();
            System.Data.OleDb.OleDbConnection iConnect = new System.Data.OleDb.OleDbConnection();
            iConnect.ConnectionString = iGet.ConnectionString();
            iConnect.Open();
            System.Data.OleDb.OleDbCommand iCommand = new System.Data.OleDb.OleDbCommand();
            iCommand.Connection = iConnect;
            iCommand.CommandText = "Select ShapeName from Shapes ";
            System.Data.OleDb.OleDbDataReader iRead = iCommand.ExecuteReader();
            while (iRead.Read())
            {
                Shape iShape = new Shape();
                iShape.ShapeName = iRead["ShapeName"].ToString();
                iList.Add(iShape.ShapeName);
            }

        }
        catch
        {
            MessageBox.Show("Someone better call batman or something `\\(^_^)_/`");
        }
        return iList;
    }

在此处输入图像描述


请注意,如果我选择任何其他带有破折号-的东西,它只会选择一个项目。没有隐藏/无效字符....

4

1 回答 1

1

您确定数据中没有换行符吗?

调试该列表中的项目计数。

 string same = "same" + Environment.NewLine + "next Line";
 List<string> lstring = new List<string> { "one", "two - a", "two - b", "three", "three", same, same };
 cb1.ItemsSource = lstring;

这具有您描述的选择行为。

于 2012-11-01T14:38:05.690 回答