找回密码
 立即注册

QQ登录

只需一步,快速开始

p332718873

论坛元老

42

主题

85

帖子

8225

积分

论坛元老

积分
8225

活字格认证

p332718873
论坛元老   /  发表于:2013-4-10 19:46  /   查看:4769  /  回复:1
1.silverlight版spread好像跟webform不一样,不支持celltype,我想在单元格中实现一个超链接的功能,点击后有相应事件,这个功能该怎么实现?
2.如果要加载超大量的数据,还是会卡死,请问有什么解决办法吗?我没找到有分页的功能。

谢谢解答~

1 个回复

倒序浏览
Zoe
银牌会员   /  发表于:2013-4-12 09:58:00
沙发
回复 1楼p332718873的帖子

问题1:

  1.   public MainPage()
  2.         {
  3.             InitializeComponent();

  4.             this.gcSpreadSheet1.Sheets.Clear();
  5.             this.gcSpreadSheet1.Sheets.Add(new MyWorksheet() { RowCount = 10, ColumnCount = 8, DefaultColumnWidth = 100, DefaultRowHeight = 28 });
  6.             var sheet = this.gcSpreadSheet1.ActiveSheet;
  7.            
  8.             var sheet1 = this.gcSpreadSheet1.ActiveSheet as MyWorksheet;
  9.             if (sheet != null)
  10.             {
  11.                 sheet1.DrawingObjectVisible = true;
  12.                 this.gcSpreadSheet1.InvalidateRange(-1, -1, -1, -1);
  13.             }
  14.         }

  15.       
  16.         public class ControlDrawingObject : CustomDrawingObject
  17.         {
  18.             private Control _rootElement;
  19.             public ControlDrawingObject(int row, int col, Control control) : base(row, col) { _rootElement = control; this.ShowDrawingObjectOnly = true; }
  20.             public override FrameworkElement RootElement
  21.             {
  22.                 get { _rootElement.Margin = new Thickness(1); return _rootElement; }
  23.             }
  24.         }

  25.         public class MyWorksheet : Worksheet
  26.         {
  27.             public bool DrawingObjectVisible { get; set; }
  28.             public override DrawingObject[] GetDrawingObject(int row, int column, int rowCount, int columnCount)
  29.             {
  30.                DrawingObject dobj;

  31.                 if (column == 0)
  32.                 {                  
  33.                     HyperlinkButton control = new HyperlinkButton();
  34.                     control.Content = "https://www.google.com.hk/";
  35.                     control.NavigateUri = new Uri("https://www.google.com.hk/");
  36.                     control.Click += new RoutedEventHandler(control_Click);
  37.                     dobj = new ControlDrawingObject(row, column, control);                    
  38.                 }
  39.                 else
  40.                 {
  41.                     return base.GetDrawingObject(row, column, rowCount, columnCount);

  42.                 }
  43.                 return new DrawingObject[] { dobj };
  44.             }

  45.             void control_Click(object sender, RoutedEventArgs e)
  46.             {
  47.                 HtmlPage.Window.Eval("window.open(\"https://www.google.com.hk\")");
  48.             }
  49.         }
复制代码


问题2:

  1. this.gcSpreadSheet1.AutoRefresh = false;
  2.             for (int i = 0; i < 10; i++)
  3.             {
  4.                 for (int j = 0; j < 8; j++)
  5.                 {
  6.                     this.gcSpreadSheet1.ActiveSheet.Cells[i, j].Value = "test";
  7.                 }

  8.             }
  9.             this.gcSpreadSheet1.AutoRefresh = true;

复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部