开发者

Set ItemsSource to DataTable Item

开发者 https://www.devze.com 2023-02-03 23:20 出处:网络
I am trying to set the itemssource for my WPF-based VB 2010 project to a datatable item. The datatable is \"roster_table\" and the column na开发者_如何学运维me I want to display the items from in the

I am trying to set the itemssource for my WPF-based VB 2010 project to a datatable item. The datatable is "roster_table" and the column na开发者_如何学运维me I want to display the items from in the list box is "DATA_NAME". The listbox is "lstNames".

My apologies if this is a dumb question, but I can't find a straight answer anywhere. How do I set the itemssource for the listbox to the datatable's column, as described above?


try this

lstNames.ItemsSource = roster_table;
lstNames.DisplayMemberPath = "DATA_NAME";

to set value to the item

lstNames.SelectedValuePath = "YOUR_ID";
0

精彩评论

暂无评论...
验证码 换一张
取 消