PDA

View Full Version : نمایش درختی در Datagrid



marzban
شنبه 25 خرداد 1387, 08:09 صبح
با سلام
شاید عنوان مناسبی را برای طرح سوالم مطرح نکرده باشم ولی سعی می کنم کا توضیح مناسبی بدهم.
من می خواهم که نتیجه یک پیمایش یک رکورد و رکورد زیر مجموعه اش را در یک دیتا گرید نمایش دهم.برای مثال اگر در ACCESS توجه کرده باشید این خصوصیت وجود دارد که زمانی شما یک Relation بین دو جدول داشته باشید در جدول والد یک علامت + در کنار نمایش رکورد ظاهر می گردد و با زدن بر روی آن + شما می توانید سایر اطلاعات وابسته به آن رکورد را مشاهده نمایید.
لطفا راهنمایی کنید
با تشکر مرزبان

Dariuosh
شنبه 25 خرداد 1387, 09:32 صبح
ديتاگريد VS اين کارو نميکنه بايد از کامپوننت هاي ديگه ايي استفاده کني

http://www.janusys.com/controls/
http://www.devexpress.com/Products/NET/WinForms/XtraGrid/

habil_57
جمعه 29 شهریور 1387, 14:15 عصر
این کد رو دیتا گرید قدیمی کار میکنه
کنترل دیتا گرید جدید همونطور که دوستمون گفت نمایش درختی به این روش نداره

Step-by-Step Example


Open Visual Studio .NET, and create a new Visual Basic Windows Application. Form1 is created by default.
Use the toolbox to add a Button control and a DataGrid control to Form1.
In the Properties window, change the Text property of the button to Load.
Double-click Load to add an event handler.
Add the following code to the top of the code window:Imports System.Data.SqlClient
Add the following code to the Button1_Click event handler:Dim con As New SqlConnection("server=YourServer;uid=UID;pwd=PWD;database=northwi nd")Dim daCust As New SqlDataAdapter("Select * From Customers Where CustomerID Like 'A%'", con)Dim daOrders As New SqlDataAdapter("Select * From Orders Where CustomerID Like 'A%'", con)Dim ds As New DataSet()daCust.Fill(ds, "Cust")daOrders.Fill(ds, "Orders")'Build the relation between Orders and Customers.ds.Relations.Add("CustOrd", ds.Tables!Cust.Columns!CustomerID, ds.Tables!Orders.Columns!CustomerID)DataGrid1.Data Source = dsDataGrid1.DataMember = "Cust"
Modify the SqlConnection string to point to a valid Microsoft SQL Server database.
Press the F5 key to compile and run the application.
Notice that the grid is empty initially. Click Load to populate the grid.
Click the plus sign (+) to display the links to the child records. In this example, one child relation appears. Click the relation to display the child records.
In the upper right corner of the grid, click the back arrow to return to the parent records.

ehsanmail2
سه شنبه 24 آذر 1388, 09:31 صبح
مي توانيد در همين رابطه به من كمك كنيد
من همين مسئله رو در vb.net 2008 دارم لطفا كمكم كنيد