首页 文章

WPO中ComponentOne Spread中的自定义CellType

提问于
浏览
0

我们目前正在将一个非常旧的VB 6应用程序迁移到.NET 4.5 WPF . 此应用程序使用旧的Farpoint Spread 7.0组件 . 旧的电子表格广泛使用了 CellTypeButton ,但是对于WTF,Spread并没有找到任何关于如何在WPF中为Spread创建自定义单元格类型的示例代码,教程和博客 .

是否可以在Spread for WPF中创建按钮?有没有人这样做过?有关如何执行此操作的任何提示,资源或指向smaples或博客的链接?

非常感谢你!

1 回答

  • 0

    你可以使用 CustomFloatingObject

    以下代码创建一个浮动对象 .

    • 实现自定义CustomFloatingObject类 .

    • 创建浮动对象内容 .

    • 将浮动对象添加到工作表 .

    参考:http://helpcentral.componentone.com/NetHelp/SpreadWPF/webframe.html#floating.html

    public class MyFloatingObject : GrapeCity.Windows.SpreadSheet.UI.CustomFloatingObject
        {
            public MyFloatingObject(string name, double x, double y, double width, double height)
                : base(name, x, y, width, height)
            {
            }
    
            public override FrameworkElement Content
            {
                get
                {
                    Border border = new Border();
    
                    StackPanel sp = new StackPanel();
                    sp.Children.Add(new Button() { Content = "Button" });
    
                    border.BorderThickness = new Thickness(1);
                    border.BorderBrush = new SolidColorBrush(Colors.Black);
                    border.Child = sp;
                    return border;
                }
            }
        }
    

    将此浮动对象的实例添加到工作表中

    MyFloatingObject mf = new MyFloatingObject("mf1", 10, 10, 200, 100);
    gcSpreadSheet1.ActiveSheet.FloatingObjects.Add(mf);
    

相关问题