代码之家  ›  专栏  ›  技术社区  ›  Ferruccio

如何获得用于Telerik RadGridView列的上下文菜单?

  •  0
  • Ferruccio  · 技术社区  · 15 年前

    private void CreateNewColumn(FieldDescriptor fd, uint fieldno) {
        fieldGrid.Columns.Add(new GridViewDataColumn() {
            UniqueName = fd.fieldName,
            Header = fd.displayName,
            DataMemberBinding = new Binding("Fields[" + fieldno + "]"),
            ContextMenu = new ContextMenu() {
                Tag = fieldno,
                Items = {
                    new MenuItem() {
                        Header = "Field Properties",
                        Command = Commands.FieldProperties,
                        CommandBindings = { new CommandBinding(Commands.FieldProperties, FieldProperties_Execute) } 
                    },
                    new MenuItem() {
                        Header = "Delete Field",
                        Command = Commands.DeleteField,
                        CommandBindings = { new CommandBinding(Commands.DeleteField, DeleteField_Execute) }
                    }
                }
            }
        });
    }
    

    fieldGrid.ContextMenu = new ContextMenu() { ...
    

    2 回复  |  直到 13 年前
        2
  •  0
  •   Bryan Batchelder    15 年前

    我不能为Telerik的网格说话,但使用Infrastics网格,您可以将上下文菜单附加到网格,然后使用鼠标位置确定用户在网格中右键单击的内容。Infragistics网格有一些合适的辅助方法来促进命中测试。