MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集 > シェイプ > カメラシェイプを追加する |
カメラシェイプを作成することで、任意のセル範囲をキャプチャーしシェイプとして配置することが可能です。下記のサンプルコードでは、Sheet2のセル範囲をキャプチャーし、Sheet1にシェイプとして配置しています。
private void Form1_Load(object sender, EventArgs e) { // シートの数を設定 fpSpread1.Sheets.Count = 2; // Sheet1の設定 fpSpread1.ActiveSheet.Rows.Default.Height = 40; fpSpread1.ActiveSheet.Columns.Default.Width = 120; // Sheet2の設定 fpSpread1.Sheets[1].Cells[0, 0].BackColor = Color.LightCoral; fpSpread1.Sheets[1].Cells[1, 1].BackColor = Color.LightCyan; fpSpread1.Sheets[1].SetValue(0, 0, "ABC"); fpSpread1.Sheets[1].SetValue(1, 1, 123); fpSpread1.Sheets[1].Cells[1, 0].CellType = new FarPoint.Win.Spread.CellType.CheckBoxCellType(); fpSpread1.Sheets[1].Cells[0, 1].CellType = new FarPoint.Win.Spread.CellType.ButtonCellType(); // カメラシェイプを設定 FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape test = new FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape(); test.Formula = "Sheet2!A1:B2"; test.Location = new System.Drawing.Point(120, 40); test.ShapeOutlineThickness = 0; test.Locked = true; fpSpread1.ActiveSheet.AddShape(test); }
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ' シートの数を設定 FpSpread1.Sheets.Count = 2 ' Sheet1の設定 FpSpread1.ActiveSheet.Rows.Default.Height = 40 FpSpread1.ActiveSheet.Columns.Default.Width = 120 ' Sheet2の設定 FpSpread1.Sheets(1).Cells(0, 0).BackColor = Color.LightCoral FpSpread1.Sheets(1).Cells(1, 1).BackColor = Color.LightCyan FpSpread1.Sheets(1).SetValue(0, 0, "ABC") FpSpread1.Sheets(1).SetValue(1, 1, 123) FpSpread1.Sheets(1).Cells(1, 0).CellType = New FarPoint.Win.Spread.CellType.CheckBoxCellType() FpSpread1.Sheets(1).Cells(0, 1).CellType = New FarPoint.Win.Spread.CellType.ButtonCellType() ' カメラシェイプを設定 Dim test As New FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape() test.Formula = "Sheet2!A1:B2" test.Location = New System.Drawing.Point(120, 40) test.ShapeOutlineThickness = 0 test.Locked = True FpSpread1.ActiveSheet.AddShape(test) End Sub