XtraGrid:获取RespositoryItemButtonEdit行索引

时间:2015-05-22 12:52:54

标签: .net vb.net devexpress xtragrid

如何在特定行索引处获取ButtonEdit

这就是我创建RepositoryItemButtonEdit列的方式。

Private Sub PopulateDataGrid()

    GrdCntrlMain.DataSource = CreateDataSet().Tables(TABLE_WORKERS)

    Dim lObj_GrdClmn As GridColumn = GrdView.Columns.AddField("Select") ' This is my RepositoryItemButtonEdit column
    With lObj_GrdClmn
        .VisibleIndex = GrdView.Columns.Count
        .OptionsColumn.AllowEdit = True
    End With

    GrdView.OptionsView.RowAutoHeight = False

    AddHandler GrdView.MouseMove, AddressOf GrdView_MouseMove

    Dim lObj_RepItm_BtnEdt As New RepositoryItemButtonEdit
    lObj_RepItm_BtnEdt.TextEditStyle = TextEditStyles.HideTextEditor

    AddHandler lObj_RepItm_BtnEdt.ButtonPressed, AddressOf lObj_EdtrBtn_Click

    Dim lObj_EdtrBtn As EditorButton = New EditorButton()
    lObj_EdtrBtn.Kind = ButtonPredefines.Glyph
    lObj_EdtrBtn.Appearance.BackColor = Color.Azure
    lObj_EdtrBtn.Caption = "Remove"
    lObj_EdtrBtn.Appearance.Options.UseTextOptions = True

    lObj_RepItm_BtnEdt.Buttons.Clear()

    lObj_RepItm_BtnEdt.Buttons.Add(lObj_EdtrBtn)

    GrdCntrlMain.RepositoryItems.Add(lObj_RepItm_BtnEdt)

    GrdView.Columns("Select").ColumnEdit = lObj_RepItm_BtnEdt

End Sub

我想在图像中突出显示第6行行的按钮。 enter image description here

我想在CellValueChanged事件中获取此按钮。

我如何获得此按钮?

1 个答案:

答案 0 :(得分:0)

根据documentation

  

单元格值由继承自BaseEdit类的编辑器编辑。   一旦用户开始编辑单元格值,就会创建单元格的编辑器。   编辑完成后,单元格编辑器将被销毁。因此,那里   任何时候都只能是一个活动的编辑器实例。

因此,如果您想从单元格中获取编辑器,则需要关注此单元格并开始编辑它。使用ColumnView.FocusedRowHandle属性和ColumnView.FocusedColumn属性将焦点设置在单元格上,并调用GridView.ShowEditor方法来调用编辑器。之后使用ColumnView.ActiveEditor属性来获取编辑器:

GrdView.FocusedRowHandle = 5 'The 6-th row handle.
GrdView.FocusedColumn = GrdView.Columns("Select")

GridView.ShowEditor

Dim editor = GridView.ActiveEditor