473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Datagrid Relation View

I wish to make a custom view of relations in a datagrid
what i want to do is when the plus sign is clicked instead of showing the
link label
i want to show a grid with the subtable in that area between the selected
grid and the next grid.

however i cannot seem to find a method of obtaing the position coordinate
for that area.? and ideas on how to go about finding the position?

WStoreyII

thanks again
Nov 20 '05 #1
2 2193
Hi,
Here is an example that uses the northwind database. Add 3
datagrids to a form. dgorders, dgorderdetails, dgemployees.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim ds As DataSet

Dim daEmployees As SqlDataAdapter

Dim daOrders As SqlDataAdapter

Dim daOrderDetails As SqlDataAdapter

Dim conn As SqlConnection

Dim strConn As String

Dim strSQL As String

Dim strItem As String

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is DataGrid Then

Dim dg As DataGrid = ctrl

dg.AllowNavigation = False

End If

Next

strConn = "Server = " + Environment.MachineName + "\VSdotNet;"

strConn += "Database = NorthWind;"

strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

ds = New DataSet

daEmployees = New SqlDataAdapter("Select * from Employees", conn)

daOrders = New SqlDataAdapter("Select * from Orders", conn)

daOrderDetails = New SqlDataAdapter("Select * from [Order Details]", conn)

daEmployees.Fill(ds, "Employee")

daOrders.Fill(ds, "Orders")

daOrderDetails.Fill(ds, "OrderDetails")

ds.Relations.Add("EmployeeOrder",
ds.Tables("Employee").Columns("EmployeeID"), _

ds.Tables("Orders").Columns("EmployeeID"))

ds.Relations.Add("Order2Details", ds.Tables("Orders").Columns("OrderID"), _

ds.Tables("OrderDetails").Columns("OrderID"))

dgEmployees.SetDataBinding(ds, "Employee")

dgOrders.SetDataBinding(ds, "Employee.EmployeeOrder")

dgOrderDetails.SetDataBinding(ds, "Employee.EmployeeOrder.Order2Details")

End Sub

Ken

--------------------

"WStoreyII" <pa**********@sbcglobal.net> wrote in message
news:45******************@newssvr27.news.prodigy.c om...
I wish to make a custom view of relations in a datagrid
what i want to do is when the plus sign is clicked instead of showing the
link label
i want to show a grid with the subtable in that area between the selected
grid and the next grid.

however i cannot seem to find a method of obtaing the position coordinate
for that area.? and ideas on how to go about finding the position?

WStoreyII

thanks again

Nov 20 '05 #2
Hi,
Here is an example that uses the northwind database. Add 3
datagrids to a form. dgorders, dgorderdetails, dgemployees.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim ds As DataSet

Dim daEmployees As SqlDataAdapter

Dim daOrders As SqlDataAdapter

Dim daOrderDetails As SqlDataAdapter

Dim conn As SqlConnection

Dim strConn As String

Dim strSQL As String

Dim strItem As String

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is DataGrid Then

Dim dg As DataGrid = ctrl

dg.AllowNavigation = False

End If

Next

strConn = "Server = " + Environment.MachineName + "\VSdotNet;"

strConn += "Database = NorthWind;"

strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

ds = New DataSet

daEmployees = New SqlDataAdapter("Select * from Employees", conn)

daOrders = New SqlDataAdapter("Select * from Orders", conn)

daOrderDetails = New SqlDataAdapter("Select * from [Order Details]", conn)

daEmployees.Fill(ds, "Employee")

daOrders.Fill(ds, "Orders")

daOrderDetails.Fill(ds, "OrderDetails")

ds.Relations.Add("EmployeeOrder",
ds.Tables("Employee").Columns("EmployeeID"), _

ds.Tables("Orders").Columns("EmployeeID"))

ds.Relations.Add("Order2Details", ds.Tables("Orders").Columns("OrderID"), _

ds.Tables("OrderDetails").Columns("OrderID"))

dgEmployees.SetDataBinding(ds, "Employee")

dgOrders.SetDataBinding(ds, "Employee.EmployeeOrder")

dgOrderDetails.SetDataBinding(ds, "Employee.EmployeeOrder.Order2Details")

End Sub

Ken

--------------------

"WStoreyII" <pa**********@sbcglobal.net> wrote in message
news:45******************@newssvr27.news.prodigy.c om...
I wish to make a custom view of relations in a datagrid
what i want to do is when the plus sign is clicked instead of showing the
link label
i want to show a grid with the subtable in that area between the selected
grid and the next grid.

however i cannot seem to find a method of obtaing the position coordinate
for that area.? and ideas on how to go about finding the position?

WStoreyII

thanks again

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sandy | last post by:
If I have two tables i.e. Authors and Titles from Pubs, and I want to display the Authors name and then all titles by a particular author in a DataGrid, how would I do that? Is there a way to...
2
by: WStoreyII | last post by:
I wish to make a custom view of relations in a datagrid what i want to do is when the plus sign is clicked instead of showing the link label i want to show a grid with the subtable in that area...
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
1
by: archana | last post by:
Hi all, I am having application where in i am having datagrid showing 2 tables with relation between them. When i click on relation which set i get records of second table in same datagrid....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.