本文介绍了XtraGrid:Get RespositoryItemButtonEdit行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to get ButtonEdit at specific row index?

这是我创建 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行行获取按钮。

I want to get button at 6th row as highlighted in image.

让说我想在 CellValueChanged 事件中获取这个按钮。

Let say I want to get this button on CellValueChanged event.

我该如何获得这个按钮?

How I can get this button?

推荐答案

根据:

所以,如果你想得到编辑器从单元格,您需要聚焦这个单元格并开始编辑它。使用属性和属性设置专注于单元格,并调用调用编辑器的方法。之后使用属性得到你的编辑器:

So, if you want to get the editor from the cell, you need to focus this cell and start to edit it. Use the ColumnView.FocusedRowHandle property and ColumnView.FocusedColumn property to set the focus on cell and call to GridView.ShowEditor method to invoke the editor. After that use ColumnView.ActiveEditor property to get your editor:

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

GridView.ShowEditor

Dim editor = GridView.ActiveEditor

这篇关于XtraGrid:Get RespositoryItemButtonEdit行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:46