2014-10-08 37 views
0

我們正在將一個非常古老的VB 6應用程序遷移到.NET 4.5 WPF。此應用程序使用舊的Farpoint Spread 7.0組件。舊電子表格廣泛使用CellTypeButton,但針對WTF的Spread不提供此單元格類型。我也沒有找到任何示例代碼,教程,以及如何爲WPF中的Spread創建自定義單元格類型的博客。ComponentOne中的自定義CellType WPF的Spread

是否可以在Spread for WPF中創建按鈕?有沒有人做過這個? 任何提示,資源或鏈接smaples或博客如何做到這一點?

非常感謝!

回答

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);