C# 选择多个项目的组合框
有人能解释一下这种行为吗C# 选择多个项目的组合框,c#,wpf,combobox,C#,Wpf,Combobox,有人能解释一下这种行为吗 MouseOver不仅突出显示多个项目(非预期),而且当我选择该项目(鼠标位于上方)时,代码会转到Selection\u Changed事件,该事件会更改右侧的图片(如预期),而且在加载图片时,出现一条错误消息,指出路径中存在无效字符 public List GetListOfShapes() { List iList=新列表(); 尝试 { GetConnectionString iGet=新建GetConnectionString(); System.Dat
MouseOver
不仅突出显示多个项目(非预期),而且当我选择该项目(鼠标位于上方)时,代码会转到Selection\u Changed事件,该事件会更改右侧的图片(如预期),而且在加载图片时,出现一条错误消息,指出路径中存在无效字符
public List GetListOfShapes()
{
List iList=新列表();
尝试
{
GetConnectionString iGet=新建GetConnectionString();
System.Data.OleDb.OleDbConnection iConnect=新的System.Data.OleDb.OleDbConnection();
iConnect.ConnectionString=iGet.ConnectionString();
i connect.Open();
System.Data.OleDb.OleDbCommand icomand=新的System.Data.OleDb.OleDbCommand();
iCommand.Connection=iConnect;
iCommand.CommandText=“从形状中选择ShapeName”;
System.Data.OleDb.OleDbDataReader iRead=iCommand.ExecuteReader();
while(iRead.Read())
{
形状iShape=新形状();
iShape.ShapeName=iRead[“ShapeName”].ToString();
iList.Add(iShape.ShapeName);
}
}
接住
{
Show(“最好有人打电话给蝙蝠侠或其他东西”\\(^^^)\/`);
}
返回iList;
}
请注意,如果我选择任何其他带有破折号的项目,它只会选择一个项目。没有隐藏/无效字符 您确定数据中没有新行字符吗
调试该列表中的项目计数
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;
string same=“same”+Environment.NewLine+“下一行”;
List lstring=新列表{“一”、“二-a”、“二-b”、“三”、“三”,相同,相同};
cb1.ItemsSource=lstring;
这就是您描述的选择行为。请解释您一直在说的“it”是什么。(“它”运行代码…“它”说…“它”只选择一项…)然后更新问题,而不是假设。组合框的选择模式是什么?底部的示例是什么?选择模式是否设置为dropdownlist?@JustinKirk:鼠标悬停在列表视图项上时,可以运行代码?您的鼠标可以“说路径中有无效字符”?那是一只神奇的啮齿动物。是你编写的程序的截图,还是其他人编写的程序的截图,你希望与之相同?您是否试图阻止它(无论“it”是什么)运行[nig]代码来填充它旁边的图像框(无论“it”是什么)。那是你写的代码吗(而且运行得太频繁?或者你需要你的代码来检测“它”运行它,然后什么也不做?)?新行只能由\n生成吗?LOL,我一直在查看代码中的错误,在access数据库中,它显示sonora是1行(如屏幕截图所示),但如果我突出显示它,并把它拉下来,它下面露出了塞多纳,我就是看不到它,因为这一排的高度-_-
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;
}
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;