如何给combox 控件绑定一个数组

liguoyun 2004-01-08 02:01:53
现有一个数组manufactory()
值为:{{"1","上海大众"},{"2","上海通用"}}

我现在想绑定到一个combox上,displaymember应该是显示“上海大众”、上海通用等内容,而valuemember应该显示相对应的数值“1”,“2”等。

我该如和做???
...全文
244 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
aqinag 2004-04-23
  • 打赏
  • 举报
回复
好,用到啦
LVOLCANO 2004-01-08
  • 打赏
  • 举报
回复
GZ
dongbeiren 2004-01-08
  • 打赏
  • 举报
回复
微软的101例子里的我觉得对你的题目整合适,不过背离了你的初衷:(

protected structure Divisions
private divName as String
private divId as string
public sub new(name as String, id as string)
divName=name
divId = id
End Sub

public readonly property getName() as String
get
return divName
End Get
end property

public readonly property getId() as string
get
return divID
End Get
End Property
End structure


dim myDivisions as new ArrayList

'add division structure entries to the arraylist
with myDivisions
.Add(new divisions("上海大众","1")
.Add(new Divisions("上海通用","2")
end With

'bind the arraylist to the combo box
With combobox1
.datasource=myDivisions
.DisplayMember = "getName"
.ValueMember = "getId"
End With
thinkingforever 2004-01-08
  • 打赏
  • 举报
回复
把他转化成一张表,然后放入dataset中,最后帮定到comboBox1.DataSource上

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧