回复 1楼p332718873的帖子
问题1:
- public MainPage()
- {
- InitializeComponent();
- this.gcSpreadSheet1.Sheets.Clear();
- this.gcSpreadSheet1.Sheets.Add(new MyWorksheet() { RowCount = 10, ColumnCount = 8, DefaultColumnWidth = 100, DefaultRowHeight = 28 });
- var sheet = this.gcSpreadSheet1.ActiveSheet;
-
- var sheet1 = this.gcSpreadSheet1.ActiveSheet as MyWorksheet;
- if (sheet != null)
- {
- sheet1.DrawingObjectVisible = true;
- this.gcSpreadSheet1.InvalidateRange(-1, -1, -1, -1);
- }
- }
-
- public class ControlDrawingObject : CustomDrawingObject
- {
- private Control _rootElement;
- public ControlDrawingObject(int row, int col, Control control) : base(row, col) { _rootElement = control; this.ShowDrawingObjectOnly = true; }
- public override FrameworkElement RootElement
- {
- get { _rootElement.Margin = new Thickness(1); return _rootElement; }
- }
- }
- public class MyWorksheet : Worksheet
- {
- public bool DrawingObjectVisible { get; set; }
- public override DrawingObject[] GetDrawingObject(int row, int column, int rowCount, int columnCount)
- {
- DrawingObject dobj;
- if (column == 0)
- {
- HyperlinkButton control = new HyperlinkButton();
- control.Content = "https://www.google.com.hk/";
- control.NavigateUri = new Uri("https://www.google.com.hk/");
- control.Click += new RoutedEventHandler(control_Click);
- dobj = new ControlDrawingObject(row, column, control);
- }
- else
- {
- return base.GetDrawingObject(row, column, rowCount, columnCount);
- }
- return new DrawingObject[] { dobj };
- }
- void control_Click(object sender, RoutedEventArgs e)
- {
- HtmlPage.Window.Eval("window.open(\"https://www.google.com.hk\")");
- }
- }
复制代码
问题2:
- this.gcSpreadSheet1.AutoRefresh = false;
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- this.gcSpreadSheet1.ActiveSheet.Cells[i, j].Value = "test";
- }
- }
- this.gcSpreadSheet1.AutoRefresh = true;
复制代码 |