ITPub博客

首页 > IT基础架构 > 网络安全 > DataGridView with multiple table

DataGridView with multiple table

原创 网络安全 作者:101OIO 时间:2008-04-11 13:16:33 0 删除 编辑
Display columns from two tables in one DataGridView

There're two ways.

One way is to use SQL( join )
one DataTable, one DataAdapter.
set "DataGridView.dataSource = DataTable". It's OK
It's very easy,but disadvantage is that you can not use "dataAdapter.update"

The other way is to use JoinView
http://support.microsoft.com/Default.aspx?scid=kb;en-us;325682
two DataTables, two DataAdapters, one JoinView
The only drawback is that if you change the data of DataTable, the JoinView can't modify accordingly. You should write ReFill() method of JoinView

Public Sub ReFill(ByVal DataTable As DataTable)
Me.Clear()
Table = DataTable
Dim Row As DataRow
For Each Row In Table.Rows
List.Add(New JoinViewRow(Me, Row))
Next
End Sub
[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/55968/viewspace-1002315/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    47
  • 访问量
    81416