您可以使用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);