MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集
罫線を設定する

CellクラスのBorderプロパティを設定します。SPREADでは罫線描画のために色々なクラスを提供していますが、ここでは基本的な罫線の設定を何種類かのパターンを用いて紹介します。

【実行例】

罫線の設定(シート拡大)

 private void Form1_Load(object sender, System.EventArgs e)
 {

  //セル(1,1)に標準罫線を設定します
  FarPoint.Win.LineBorder lBorder = new FarPoint.Win.LineBorder(Color.Pink, 3);
  fpSpread1.ActiveSheet.Cells[1, 1].Border = lBorder;

  //セル(3,1)に複合罫線を設定します
  FarPoint.Win.ComplexBorderSide cbs1 = new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine, Color.Red);
  FarPoint.Win.ComplexBorderSide cbs2 = new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.DoubleLine, Color.Blue);
  FarPoint.Win.ComplexBorderSide cbs3 = new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.DashDot, Color.Green);
  FarPoint.Win.ComplexBorderSide cbs4 = new FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.MediumDashed, Color.Yellow);
  FarPoint.Win.ComplexBorder cBorder = new FarPoint.Win.ComplexBorder(cbs1, cbs2, cbs3, cbs4);
  fpSpread1.ActiveSheet.Cells[3, 1].Border = cBorder;

  //セル(5,1)にベベル罫線を設定します
  FarPoint.Win.BevelBorder bBorder = new FarPoint.Win.BevelBorder(FarPoint.Win.BevelBorderType.Raised, Color.Cyan, Color.DarkCyan, 2);
  fpSpread1.ActiveSheet.Cells[5, 1].Border = bBorder;

 }
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

  'セル(1,1)に標準罫線を設定します
  Dim lBorder As New FarPoint.Win.LineBorder(Color.Pink, 3)
  FpSpread1.ActiveSheet.Cells(1, 1).Border = lBorder

  'セル(3,1)に複合罫線を設定します
  Dim cbs1 As New FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.ThickLine, Color.Red)
  Dim cbs2 As New FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.DoubleLine, Color.Blue)
  Dim cbs3 As New FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.DashDot, Color.Green)
  Dim cbs4 As New FarPoint.Win.ComplexBorderSide(FarPoint.Win.ComplexBorderSideStyle.MediumDashed, Color.Yellow)
  Dim cBorder As New FarPoint.Win.ComplexBorder(cbs1, cbs2, cbs3, cbs4)
  FpSpread1.ActiveSheet.Cells(3, 1).Border = cBorder

  'セル(5,1)にベベル罫線を設定します
  Dim bBorder As New FarPoint.Win.BevelBorder(FarPoint.Win.BevelBorderType.Raised, Color.Cyan, Color.DarkCyan, 2)
  FpSpread1.ActiveSheet.Cells(5, 1).Border = bBorder

 End Sub

 

 


© MESCIUS inc. All rights reserved.