毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

dev gridcontrol的下拉列表每行绑定不同数据源

更新时间:2013-6-12:  来源:毕业论文

dev gridcontrol的下拉列表每行绑定不同数据源

dev grid中下拉列表默认的数据源绑定在列上面的,我需要每行的下拉框都绑定不同的数据源啊,请问怎么做呢?

我需要每行的下拉列表框都可以在后台绑定不同的数据源.并且选中一行的时候不影响其他行选中的数据.

相当于级联的意思.

比如我一列选择了 江苏,然后下一列数据源就可以在后台绑定苏州,南京.

请问怎么做呢?

实际Demo里有

Visual Basic code?Private Sub InitData()             Dim records(9) As Record             records(0) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.ProductName, "Mishi Kobe Niku", "Teatime Chocolate Biscuits", "Ipoh Coffee")             records(1) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.Category, 6, 3, 1)             records(2) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.Supplier, "Tokyo Traders", "Specialty Biscuits, Ltd.", "Leka Trading")             records(3) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.QuantityPerUnit, "18 - 500 g pkgs.", "10 boxes x 12 pieces", "16 - 500 g tins")             records(4) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.UnitPrice, 97.0, 9.2, 46.0)             records(5) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.UnitsInStock, 29, 25, 17)             records(6) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.Discontinued, False, True, True)             records(7) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.LastOrder, New DateTime(2001, 12, 14), New DateTime(2003, 7, 20), New DateTime(2002, 1, 7))             records(8) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.Picture, ImageToByteArray(GetImage("product1.jpg")), ImageToByteArray(GetImage("product2.jpg")), ImageToByteArray(GetImage("product3.jpg")))             records(9) = New Record(DevExpress.XtraGrid.Demos.Properties.Resources.Relevance, 70, 90, 50)               gridControl1.DataSource = records         End Sub' Private Sub gridView1_CustomRowCellEdit(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs) Handles gridView1.CustomRowCellEdit             If e.Column.FieldName <> "Category" Then                Dim rec As Record = TryCast(gridView1.GetRow(e.RowHandle), Record)                 If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.Category Then                    e.RepositoryItem = repositoryItemImageComboBox1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.Supplier Then                    e.RepositoryItem = repositoryItemComboBox1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.UnitPrice Then                    e.RepositoryItem = repositoryItemCalcEdit1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.UnitsInStock Then                    e.RepositoryItem = repositoryItemSpinEdit1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.Discontinued Then                    e.RepositoryItem = repositoryItemCheckEdit1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.Discontinued Then                    e.RepositoryItem = repositoryItemCheckEdit1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.LastOrder Then                    e.RepositoryItem = repositoryItemDateEdit1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.Picture Then                    e.RepositoryItem = repositoryItemPictureEdit1                 End If                If rec.Category = DevExpress.XtraGrid.Demos.Properties.Resources.Relevance Then                    e.RepositoryItem = repositoryItemProgressBar1                 End If            End If        End Sub'     Public Class Record         Private fcategory As String        Private fproduct1 As Object        Private fproduct2 As Object        Private fproduct3 As Object          Public Sub New(ByVal fcategory As String, ByVal fproduct1 As Object, ByVal fproduct2 As Object, ByVal fproduct3 As Object)             Me.fcategory = fcategory             Me.fproduct1 = fproduct1             Me.fproduct2 = fproduct2             Me.fproduct3 = fproduct3         End Sub          Public ReadOnly Property Category() As String            Get                Return fcategory             End Get        End Property          Public Property Product1() As Object            Get                Return fproduct1             End Get            Set(ByVal value As Object)                 fproduct1 = value             End Set        End Property          Public Property Product2() As Object            Get                Return fproduct2             End Get            Set(ByVal value As Object)                 fproduct2 = value             End Set        End Property          Public Property Product3() As Object            Get                Return fproduct3             End Get            Set(ByVal value As Object)                 fproduct3 = value             End Set        End Property    End Class
前一段时间刚处理了这个问题的。
在CustomRowCellEditForEditing这个事件中处理的。
在grid中添加一隐藏列,当点击第一级下拉框时,将选中的value存入该行的隐藏列中,在点击第二级下拉框时,根据该行隐藏列的值查询出第二级下拉框的数据,为其绑定。

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。