当前位置: 首页>>代码示例>>C#>>正文


C# Sheet.ShowValue方法代码示例

本文整理汇总了C#中Sheet.ShowValue方法的典型用法代码示例。如果您正苦于以下问题:C# Sheet.ShowValue方法的具体用法?C# Sheet.ShowValue怎么用?C# Sheet.ShowValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sheet的用法示例。


在下文中一共展示了Sheet.ShowValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SheetTab

 public SheetTab(WorkbookForm gui, Sheet sheet)
     : base(sheet.Name)
 {
     this.gui = gui;
       this.sheet = sheet;
       this.Name = sheet.Name;
       this.dgv = new DataGridView();
       dgv.ShowEditingIcon = false;
       dgv.Dock = DockStyle.Fill;
       Dock = DockStyle.Fill;
       // Display formula in the current cell and computed value in other cells
       dgv.CellFormatting +=
     delegate(Object sender, DataGridViewCellFormattingEventArgs e) {
       int col = e.ColumnIndex, row = e.RowIndex;
       if (col == dgv.CurrentCellAddress.X && row == dgv.CurrentCellAddress.Y) {
     Object obj = sheet.Show(col, row);
     if (obj != null) {
       e.Value = obj;
       e.FormattingApplied = true;
     }
       } else {
     Object obj = sheet.ShowValue(col, row);
     if (obj != null) {
       e.Value = obj;
       e.FormattingApplied = true;
     }
       }
     };
       // Show current cell's address, and show formula in formula box
       dgv.CellEnter +=
     delegate(Object sender, DataGridViewCellEventArgs arg) {
       int row = arg.RowIndex, col = arg.ColumnIndex;
       dgv.TopLeftHeaderCell.Value = new CellAddr(col, row).ToString();
       gui.formulaBox.Text = (String)dgv.CurrentCell.FormattedValue;
     };
       // Check that cell's contents is well-formed after edit
       dgv.CellValidating +=
     delegate(Object sender, DataGridViewCellValidatingEventArgs arg) {
       if (dgv.IsCurrentCellInEditMode) {   // Update only if cell was edited
     int row = arg.RowIndex, col = arg.ColumnIndex;
     Object value = arg.FormattedValue;
     if (value != null)
       SetCell(col, row, value.ToString(), arg);
       }
     };
       // Experiment with painting on the data grid view
       dgv.Paint += delegate(Object sender, PaintEventArgs arg) {
     base.OnPaint(arg);
     // Update column and row offset tables for drawing arrows between cells:
     int offset = dgv.RowHeadersWidth;
     for (int col = 0; col < sheet.Cols; col++) {
       colOffset[col] = offset;
       offset += dgv.Columns[col].Width;
     }
     colOffset[sheet.Cols] = offset;
     offset = dgv.ColumnHeadersHeight;
     for (int row = 0; row < sheet.Rows; row++) {
       rowOffset[row] = offset;
       offset += dgv.Rows[row].Height;
     }
     rowOffset[sheet.Rows] = offset;
     Pen pen = new Pen(Color.Blue, 1);
     pen.EndCap = SDD2D.LineCap.ArrowAnchor;
     pen.StartCap = SDD2D.LineCap.RoundAnchor;
     if (dgv.SelectedCells.Count > 0) {
       DataGridViewCell dgvc = dgv.SelectedCells[0];
       CellAddr ca = new CellAddr(dgvc.ColumnIndex, dgvc.RowIndex);
       Graphics g = arg.Graphics;
       g.SmoothingMode = SDD2D.SmoothingMode.AntiAlias;
       int x = dgv.RowHeadersWidth, y = dgv.ColumnHeadersHeight,
       w = dgv.DisplayRectangle.Width - x, h = dgv.DisplayRectangle.Height - y;
       // Clip headers *before* the scroll translation/transform
       g.Clip = new Region(new Rectangle(x, y, w, h));
       g.Transform = new SDD2D.Matrix(1, 0, 0, 1,
     -dgv.HorizontalScrollingOffset, -dgv.VerticalScrollingOffset);
       SupportArea.IdempotentForeach = false; // Draw all arrows into a cell
       DrawDependents(g, pen, gui.dependentsDepth, ca, new HashSet<CellAddr>());
       DrawPrecedents(g, pen, gui.precedentsDepth, ca, new HashSet<CellAddr>());
     }
       };
       dgv.SelectionChanged += delegate(Object sender, EventArgs arg) {
     if (gui.dependentsDepth != 0 || gui.precedentsDepth != 0) {
       gui.dependentsDepth = gui.precedentsDepth = 0;
       Refresh();
     }
       };
       // Strange: to hold sheet, we need an extra row, but not an extra column?
       dgv.ColumnCount = sheet.Cols;
       dgv.RowCount = sheet.Rows + 1;
       // Allocate offset tables to assist drawing arrows between cells
       colOffset = new int[sheet.Cols + 1];
       rowOffset = new int[sheet.Rows + 1];
       dgv.AllowUserToAddRows = false;
       // Put labels on columns and rows, disable (meaningless) row sorting:
       for (int col = 0; col < dgv.ColumnCount; col++) {
     dgv.Columns[col].Name = CellAddr.ColumnName(col);
     dgv.Columns[col].SortMode = DataGridViewColumnSortMode.NotSortable;
       }
       for (int row = 0; row < dgv.RowCount; row++)
     dgv.Rows[row].HeaderCell.Value = (row + 1).ToString();
//.........这里部分代码省略.........
开发者ID:Dugin13,项目名称:P10,代码行数:101,代码来源:GUI.cs


注:本文中的Sheet.ShowValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。