从Devexpress-GridviewCell获取RepositoryItem(作为控件)

时间:2014-09-01 11:10:46

标签: vb.net gridview devexpress

我使用的devexpress Gridcontrol/Gridview有4列

Name: String
Description: String
Action: RepositoryItemLookUpEdit
Info: RepositoryItemHyperLinkEdit

现在我想写一个updates Action-column的函数,但只有当Value datasource中包含RepositoryItemLookUpEdit时才会这样做p>

所以我开始编写代码,这就是我得到的方式:

For i As Integer = 0 To GridViewDD.RowCount - 1
    Dim j As Integer = i
    Dim rItemlookup As RepositoryItemLookUpEdit = CType(GridViewDD.GetRow(i), DataRowView).Item("Actions")
    If CType(rItemlookup.DataSource, List(Of String)).Contains(curraction) Then
         // Do update of the datasource here (which works)
    End If
Next

GridControlDD.RefreshDataSource()

我的问题在于:

Dim rItemlookup As RepositoryItemLookUpEdit = CType(GridViewDD.GetRow(i), DataRowView).Item("Actions")

问题: 如何在devexpress(或其数据源)中获取单元格的RepositoryItemLookUpEdit?

注意: 我的gridview(GridViewDD)的数据源是ListRepositoryItemLookUpEdit Action的数据源总是List(Of String)

注2: 我的contents从行到行的datasource may vary

2 个答案:

答案 0 :(得分:1)

您可以轻松地从GridColumn.ColumnEdit财产获取RepositoryItem 这是一个例子:

Dim rItemlookup As RepositoryItemLookUpEdit = GridViewDD.Columns("Action").ColumnEdit

'...

For i As Integer = 0 To GridViewDD.RowCount - 1
    Dim j As Integer = i

    If CType(rItemlookup.DataSource, List(Of String)).Contains(curraction) Then
         '... Do update of the datasource here (which works)
    End If
Next

GridControlDD.RefreshDataSource()

答案 1 :(得分:0)

我找到了。感谢'很多'小时浏览devexpress论坛。使用GridviewinfoGridDataRowInfo,您可以轻松访问网格内隐藏的控件

在我的情况下,代码如下所示

Dim gvInfo As GridViewInfo = GridViewDD.GetViewInfo()
Dim rInfo As GridDataRowInfo = gvInfo.RowsInfo.FindRow(i)
Dim rItemlookup As RepositoryItemLookUpEdit = rInfo.Cells(GridViewDragDrop.Columns.Item("Actions")).Editor

您现在可以使用rItemlookup更改或访问其属性。

我希望这对任何人都有用。