XtraGrid:Get RespositoryItemButtonEdit行索引 [英] XtraGrid: Get RespositoryItemButtonEdit row index

查看:492
本文介绍了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?

推荐答案

根据文档


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

Cell values are edited by editors inherited from the BaseEdit class. Once a user starts to edit a cell value, the cell's editor is created. When editing is complete, the cell editor is destroyed. Thus, there can be only one active editor instance at any moment.

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

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行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆