mysql 获取数据 输入出到wpf 下拉框

问题遇到的现象和发生背景

mysql 获取数据 输入出到wpf 下拉框 帮忙看看出错原因

问题相关代码,请勿粘贴截图

img

img

img


                List<string> list = new List<string>();
                list=dt.AsEnumerable().Select(t=>t.Field<string>("列名").ToString()).ToList();

然后绑定到这个List试试

WLType_combox.ItemSource = dt.DefaultView; 这个改为WLType_combox.ItemsSource = dt;试下//数据源应该为dt这个对象

不是这样绑定的

代码看上去没问题,你打个断点看看Table拿到数据了没。 另外,你最后一张截图是下拉框?

img

combobox不能直接显示datarowview类型的数据,可以定义一个string类型的泛型集合,把数据放在里面作为combobox的数据源,望采纳