DataList Control in vb.net windows application forms

夙愿已清 提交于 2019-12-25 03:06:55

问题


I am upgrading my application from vb6 to vb.net.

I used to populate my data in datalist control in vb6 forms. I am not finding it in vb.net windows form application. Which one control is the equivalent to it?

How can i list my data in that control?

just like: I had a table with data like id, name

I want the name should be the displayed column and id the bound column? how can i do that


回答1:


I'm not exactly sure but I think you're looking for a ListBox. You create a class with 2 members and a property for each (suggested property names ID and Name), create a list of them and put all your data in there and then just set the 'ListBox.DisplayMember' to "Name" and ListBox.ValueMember to "ID".

The MSDN page for ListControl.DisplayMember has a full sample showing how to do it as can be seen here.

Though I'd suggest that you use a List(Of YourClass) rather than the ArrayList in the sample.



来源:https://stackoverflow.com/questions/2983462/datalist-control-in-vb-net-windows-application-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!