"如何在单个Datagridview-VB.NET中显示所有表字段“ [英] " How To Show All Table Fields in Single Datagridview-VB.NET "

查看:67
本文介绍了"如何在单个Datagridview-VB.NET中显示所有表字段“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊重所有人,



Am使用vb.net 2008和数据库是MS Access 2007。我在访问中创建了一条记录。记录名称是Country.accdb(访问数据库),我在那里制作了3个表。

Respected All ,

Am Using vb.net 2008 and Database is MS Access 2007 .I Created one record in access . Record name is " Country.accdb ( access database ) " and i made 3 Tables there .

1  India
2  Australia
3  USA



所有表格字段相同。



人名,年龄,职业。



我通过数据库向导将此访问数据库连接到Vb.net。现在我得到了'Countrydataset.xsd'。我在表格上拖了INDIA Datagridview并拖了详细信息。后来我做了3个按钮。 。按钮名称,




All tables Fields Are same .

Person Name , Age , Occupation .

I Connected This access database To Vb.net Through Database Wizard . Now i got ' Countrydataset.xsd '.Afterthat I Dragged INDIA Datagridview on form And Dragged Details Also . Afterthat I made 3 Buttons . . Button Names ,

1 India
2 Australia
3 USA





如果我单击INDIA需要在同一数据网格中显示字段详细信息



如果我点击AUSTRALIA需要在同一数据网格中显示字段详细信息



如果我点击USA需要在同一个数据网格中显示Fieldd Etails



请注意我只有一个datagridview。



如何在单个datagridview中显示所有表字段详细信息。实际上所有领域都是一样的。 Thatsy正在寻找likethis。现在我被困了。我的代码如下。如果有人知道这个问题,请回答我这对我很有帮助。感谢你......





If I Click INDIA need to show field Details in Same Datagridview

If I Click AUSTRALIA need to show Field Details in Same Datagridview

If I Click USA need to show Fieldd etails in Same Datagridview

Please be note that i have only One datagridview .

How to Display All table fields Details in Single datagridview . Actually all fields are same . Thatsy am looking likethis . Now am stuckuped.My code is given below . If anyone knows about this question please answer me It will great help for me . Thanking you ......

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'CountryDataSet.India' table. You can move, or remove it, as needed.
        Me.IndiaTableAdapter.Fill(Me.CountryDataSet.India)

    End Sub


    Private Sub IndiaBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IndiaBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.IndiaBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.CountryDataSet)

    End Sub
End Class

推荐答案

听起来你需要的就是这样:

It really sounds like all you need is something like this:
Private Sub ButtonClick(sender As System.Object, e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
    DataGridView1.AutoGenerateColumns = True
    DataGridView1.DataSource = CountryDataSet
    DataGridView1.DataMember = DirectCast(sender, Button).Text
End Sub





这假定为t在单击任何按钮之前,数据集已完全加载,并且您只想一次查看一个表。如果要同时查看多个表,则必须将其数据合并为一个或手动将数据加载到数据中。



This assumes the dataset is completely loaded before any buttons are clicked, and that you only want to see one table at a time. If you want to see multiple tables at once, you'll have to merge their data into one or manually load the grid with the data.


这篇关于"如何在单个Datagridview-VB.NET中显示所有表字段“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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