DataList Control in vb.net windows application for

2019-08-31 08:11发布

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条回答
三岁会撩人
2楼-- · 2019-08-31 08:51

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.

查看更多
登录 后发表回答