从另一个表列的内容填充一个列表框 [英] Populating a list box from the contents of another table column

查看:85
本文介绍了从另一个表列的内容填充一个列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要从另一个表中的字段填充一个列表框.
用户将条目添加到table_1,并且为了更新table_2,他们需要能够通过列表框在数据输入表单中为table_2选择正确的项.

有人对实现此目标的最佳方法有任何想法吗?
谢谢

Hi,
I need to populate a list box from a field in another table.
Users will add entries into table_1 and in order to update table_2, they need to be able to select the correct item in the data entry form for for table_2, via a listbox.

Anyone any ideas on the best way to do this?
Thanks

推荐答案

在这里我假设您必须在列表框中加载标题,并根据文档标题
将能够更新
在列表框中将标题加载为
I assume here that you must load the Listbox with the titles and On the Basis of your Document Title you
will able to update
load the Titles in listbox as
Public Sub Listboxdisp()
      Dim sd As New SqlDataAdapter("Select * from tableName", Mycon.con())
      Dim dt As New DataTable
      sd.Fill(dt)
      For i As Integer = 0 To dt.Rows.Count - 1
          ListBox1.Items.Add(dt.Rows(i).Item("Title"))
      Next


  End Sub


可以在表单加载或单击任何按钮时调用它
在数据输入端"上,放置一个文本框,以便每当用户从列表框选择标题时.在列表框上将其填充为所选索引已更改事件


may you can call this on form load or on any button click
On the Data Entry Side place a textbox so that whenever the user selects the title from listbox.. It gets filled do it as, on the listbox Selected index Changed Event

TextBox1.Text = ListBox1.Text


然后用户可以输入Require信息,然后可以更新
可能对您有帮助.我假设标题为主键.
根据您的需要实施


And then user can input the Require info, than can update
may this can help you.I have assumed the Title As the Primary key.
Implement this as per your Need


这篇关于从另一个表列的内容填充一个列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆