473,388 Members | 1,215 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,388 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 2197
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.