在表单上显示记录... [英] Displaying records on a form...

查看:118
本文介绍了在表单上显示记录...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我对VB.Net和数据库编程比较陌生。

我有一个包含四个表的数据库,设置为如下:


tblBook

BookID ... key

Book ...所有圣经的书名
tblChapter

章节ID ...密钥

章节......章节编号(1 - 150)

tblVerse
VerseID ...键

诗歌...经文编号(1 - 100)

tblVerseText

ID ... key

BookID

ChapterID

VerseID

VerseText ...圣经中的每一节经文,每一节都有自己的经文记录


在VB.Net中,我有一个包含三个ComboBox和一个标签的表单:


cmbBook ...显示所有书籍标题

cmbChapter ...显示所有章节编号

cmbVerse ...显示所有诗歌编号

lblVerseText ... to显示对应于

中三个ComboBoxes <中所做选择的经文br />

我可以让每个ComboBox显示来自相应的

表的信息,但是,我希望能够过滤每个后续的ComboBox,并且

标签,仅显示前面

选择所共有的信息。


例如:


你在cmbBook中选择''Genesis'',而cmbChapter只会显示

数字1 - 22,(Genesis中的章节数)。

然后你在cmbChapter中选择''1',而cmbVerse只会显示

数字1 - 31,(Genesis-1中的经文数量)。

然后你在cmbVerse中选择''1',而lblVerseText只会显示

诗句Genesis,1,1。


如前所述,我可以让每个ComboBox显示来自各自表格的所有

对应数据,但我想根据当前选择的数据过滤

数据COmboBoxes。


任何帮助都会非常感激,


Gary

Hi everyone,

I am relatively new to VB.Net, and database programming.
I have a database with four tables, set up as follows:

tblBook
BookID... key
Book... All the book titles of the Bible
tblChapter
ChapterID... key
Chapter... chapter numbers (1 - 150)
tblVerse
VerseID... key
Verse... verse number (1 - 100)
tblVerseText
ID... key
BookID
ChapterID
VerseID
VerseText... Each verse from the Bible, each in its own record

In VB.Net, I have a form with three ComboBoxes and one Label:

cmbBook... to display all the Book titles
cmbChapter... to display all the Chapter numbers
cmbVerse... to display all the verse numbers
lblVerseText... to display the verse corresponding to the selections made in
the three ComboBoxes

I can get each ComboBox to display the information from the corresponding
tables, however, I want to be able to filter each subsequent ComboBox, and
the label, to display only the information that is common to the preceding
selection.

For example:

You select ''Genesis'' in cmbBook, and cmbChapter will only display the
numbers 1 - 22, (the number of chapters in Genesis).
Then you select ''1'' in cmbChapter, and cmbVerse will only display the
numbers 1 - 31, (the number of verses in Genesis-1).
Then you select ''1'' in cmbVerse, and lblVerseText will only display the
verse Genesis,1,1.

As I stated earlier, I can get each ComboBox to display ALL of the
corresponding data from their respective tables, but I would like to filter
the data according to the data currently selected in any of the COmboBoxes.

Any help would be gretly appreciated,

Gary

推荐答案

单向。 。 。


对于每个dataTable,设置一个DataView。在selectedIndexChanged事件中,

将级联组合框的过滤器参数更改为与上述关系中的

键对应。将组合框绑定到DataView而不是

表,除了主表。


另一种方式,


是为每个表关系设置关系,并设置绑定,以便辅助框从关系中获取数据。我用网格做了这个

但不是用组合框但它应该可以工作。

OHM

Bo Diddly写道:
One way . . .

For each dataTable, set up a DataView. In the selectedIndexChanged event
change the filter parameters of cascading combo boxes to correspond with the
key found in the relation above. Bind the comboboxes to the DataView not the
table, except the master table.

Another way,

Is to set up relations for each table relation, and set up the binding so
the secondary boxes get the data from the relation. Ive done this with grids
but not with combo boxes but it should work.
OHM
Bo Diddly wrote:
大家好,

我对VB.Net和数据库编程比较陌生。
我有一个包含四个表的数据库,设置如下:
tblBook
BookID ... key
Book ...所有圣经的书名
tblChapter
ChapterID ... key
章......章号(1 - 150)
tblVerse
VerseID ... key
Verse ...经文编号(1 - 100)
tblVerseText
ID ... key
BookID
章节
VerseID
VerseText ...圣经中的每节经文,每节都有自己的记录

在VB.Net中,我有一个表格三个组合框和一个标签:

cmbBook ...显示所有图书标题
cmbChapter ...显示所有章节编号
cmbVerse ...显示所有诗句数字
lblVerseText ...来显示对应于三个组合框中所做选择的经文

我可以让每个ComboBox显示来自
对应表的信息,但是,我希望能够过滤每个后续的ComboBox和标签,只显示前面选择的共同信息。

例如:

你选择cmbBook中的''Genesis''和cmbChapter只显示数字1 - 22,(Genesis中的章节数)。
然后你在cmbChapter中选择''1',cmbVerse将只显示数字1 - 31,(Genesis-1中经文的数量)。
然后你在cmbVerse中选择''1',而lblVerseText只会显示创世纪的诗句,1,1。

正如我之前所说,我可以让每个ComboBox显示来自各自表格的所有相应数据,但我想过滤数据根据当前选择的任何数据
COmboBoxes。

任何帮助都会非常感激,

Gary
Hi everyone,

I am relatively new to VB.Net, and database programming.
I have a database with four tables, set up as follows:

tblBook
BookID... key
Book... All the book titles of the Bible
tblChapter
ChapterID... key
Chapter... chapter numbers (1 - 150)
tblVerse
VerseID... key
Verse... verse number (1 - 100)
tblVerseText
ID... key
BookID
ChapterID
VerseID
VerseText... Each verse from the Bible, each in its own record

In VB.Net, I have a form with three ComboBoxes and one Label:

cmbBook... to display all the Book titles
cmbChapter... to display all the Chapter numbers
cmbVerse... to display all the verse numbers
lblVerseText... to display the verse corresponding to the selections
made in the three ComboBoxes

I can get each ComboBox to display the information from the
corresponding tables, however, I want to be able to filter each
subsequent ComboBox, and the label, to display only the information
that is common to the preceding selection.

For example:

You select ''Genesis'' in cmbBook, and cmbChapter will only display the
numbers 1 - 22, (the number of chapters in Genesis).
Then you select ''1'' in cmbChapter, and cmbVerse will only display the
numbers 1 - 31, (the number of verses in Genesis-1).
Then you select ''1'' in cmbVerse, and lblVerseText will only display
the verse Genesis,1,1.

As I stated earlier, I can get each ComboBox to display ALL of the
corresponding data from their respective tables, but I would like to
filter the data according to the data currently selected in any of
the COmboBoxes.

Any help would be gretly appreciated,

Gary




问候 - OHM#OneHandedMan {at} BTInternet {dot} com



Regards - OHM# OneHandedMan{at}BTInternet{dot}com


Hi Bo Diddy,


除了关于组合框的OHM,

看看组合框中的数据源,数据库和值成员,

使用它并不是我想的那么难,


Cor
Hi Bo Diddy,

In addition to OHM about the comboboxes,
have a look at datasource, datamembers, and value members from the combobox,
using that it is not that difficult I thought,

Cor


感谢OHM和Cor,


一旦我有机会,我会尽快尝试,也许在明天之前

(星期六),我会告诉你。''


Gary
Thank you to OHM and Cor,

I will try it out as soon as I get a chance, maybe before tomorrow
(Saturday), and I will let you know.''

Gary


这篇关于在表单上显示记录...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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