vb.net中的DataList控件Windows应用程序窗体 [英] DataList Control in vb.net windows application forms
问题描述
我正在将应用程序从vb6升级到vb.net。
I am upgrading my application from vb6 to vb.net.
我曾经以vb6格式在datalist控件中填充数据。我没有在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?
喜欢:
我有一个表格,其数据像id,name
just like: I had a table with data like id, name
我想要的名字应该是显示的列和id的绑定列?我怎么可以这样做
I want the name should be the displayed column and id the bound column? how can i do that
推荐答案
我不太确定,但我想你正在寻找一个 ListBox
。您创建一个具有2个成员和一个属性的类(建议的属性名称 ID
和名称
),创建一个列表并将所有数据放在那里,然后将ListBox.DisplayMember设置为Name,将 ListBox.ValueMember
设置为ID。
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".
ListControl.DisplayMember
的MSDN页面有一个完整的示例,显示了如何看待 here 。
The MSDN page for ListControl.DisplayMember
has a full sample showing how to do it as can be seen here.
虽然我建议您使用 List(Of YourClass)
而不是 ArrayList
样本。
Though I'd suggest that you use a List(Of YourClass)
rather than the ArrayList
in the sample.
这篇关于vb.net中的DataList控件Windows应用程序窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!