MESCIUS SPREAD for Windows Forms 15.0J サンプルコード集
グループ化を有効にする

ドラッグによるグループ化を有効にするには、FpSpreadクラスのAllowColumnMoveプロパティ、SheetViewクラスのAllowGroupプロパティおよびGroupBarInfoクラスのVisibleプロパティをそれぞれTrueに設定します。

【実行例】 フォームロード時

フォームロード時

【実行例】 グループ化後

グループ化後

  • グループ化機能といくつかの機能(ソートや行フィルタリングなど)は併用することができません。詳細については、製品ヘルプの「Web サイトグループ化の制限事項」を参照してください。

 private void Form1_Load(object sender, EventArgs e)
 {

   // ドラッグによるグループ化を許可します
   fpSpread1.AllowColumnMove = true;
   fpSpread1.ActiveSheet.AllowGroup = true;
   fpSpread1.ActiveSheet.GroupBarInfo.Visible = true;

   // グループバーの表示スタイルを設定します
   fpSpread1.ActiveSheet.GroupBarInfo.Text = "ここにドラッグします";
   fpSpread1.ActiveSheet.GroupBarInfo.BackColor = Color.LightCyan;
   fpSpread1.ActiveSheet.GroupBarInfo.ForeColor = Color.Red;
   fpSpread1.ActiveSheet.GroupBarInfo.Font = new Font("MS ゴシック", 10, FontStyle.Underline);
   fpSpread1.ActiveSheet.GroupBarInfo.Height = 40;

   fpSpread1.ActiveSheet.ColumnCount = 4;
   fpSpread1.ActiveSheet.RowCount = 4;
   fpSpread1.ActiveSheet.Columns[0].Label = "名前";
   fpSpread1.ActiveSheet.Columns[1].Label = "性別";
   fpSpread1.ActiveSheet.Columns[2].Label = "報酬";
   fpSpread1.ActiveSheet.Columns[3].Label = "職業";
   fpSpread1.ActiveSheet.Cells[0, 0].Value = "Jack";
   fpSpread1.ActiveSheet.Cells[0, 1].Value = "Male";
   fpSpread1.ActiveSheet.Cells[0, 2].Value = "3000 USD";
   fpSpread1.ActiveSheet.Cells[0, 3].Value = "Teacher";
   fpSpread1.ActiveSheet.Cells[1, 0].Value = "Tommy";
   fpSpread1.ActiveSheet.Cells[1, 1].Value = "Male";
   fpSpread1.ActiveSheet.Cells[1, 2].Value = "3000 USD";
   fpSpread1.ActiveSheet.Cells[1, 3].Value = "Developer";
   fpSpread1.ActiveSheet.Cells[2, 0].Value = "Cassie";
   fpSpread1.ActiveSheet.Cells[2, 1].Value = "FeMale";
   fpSpread1.ActiveSheet.Cells[2, 2].Value = "3200 USD";
   fpSpread1.ActiveSheet.Cells[2, 3].Value = "Teacher";
   fpSpread1.ActiveSheet.Cells[3, 0].Value = "Mary";
   fpSpread1.ActiveSheet.Cells[3, 1].Value = "FeMale";
   fpSpread1.ActiveSheet.Cells[3, 2].Value = "2700 USD";
   fpSpread1.ActiveSheet.Cells[3, 3].Value = "Accountant";

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

  ' ドラッグによるグループ化を許可します
  FpSpread1.AllowColumnMove = True
  FpSpread1.ActiveSheet.AllowGroup = True
  FpSpread1.ActiveSheet.GroupBarInfo.Visible = True

  ' グループバーの表示スタイルを設定します
  FpSpread1.ActiveSheet.GroupBarInfo.Text = "ここにドラッグします"
  FpSpread1.ActiveSheet.GroupBarInfo.BackColor = Color.LightCyan
  FpSpread1.ActiveSheet.GroupBarInfo.ForeColor = Color.Red
  FpSpread1.ActiveSheet.GroupBarInfo.Font = New Font("MS ゴシック", 10, FontStyle.Underline)
  FpSpread1.ActiveSheet.GroupBarInfo.Height = 40

  FpSpread1.ActiveSheet.ColumnCount = 4
  FpSpread1.ActiveSheet.RowCount = 4
  FpSpread1.ActiveSheet.Columns(0).Label = "名前"
  FpSpread1.ActiveSheet.Columns(1).Label = "性別"
  FpSpread1.ActiveSheet.Columns(2).Label = "報酬"
  FpSpread1.ActiveSheet.Columns(3).Label = "職業"
  FpSpread1.ActiveSheet.Cells(0, 0).Value = "Jack"
  FpSpread1.ActiveSheet.Cells(0, 1).Value = "Male"
  FpSpread1.ActiveSheet.Cells(0, 2).Value = "3000 USD"
  FpSpread1.ActiveSheet.Cells(0, 3).Value = "Teacher"
  FpSpread1.ActiveSheet.Cells(1, 0).Value = "Tommy"
  FpSpread1.ActiveSheet.Cells(1, 1).Value = "Male"
  FpSpread1.ActiveSheet.Cells(1, 2).Value = "3000 USD"
  FpSpread1.ActiveSheet.Cells(1, 3).Value = "Developer"
  FpSpread1.ActiveSheet.Cells(2, 0).Value = "Cassie"
  FpSpread1.ActiveSheet.Cells(2, 1).Value = "FeMale"
  FpSpread1.ActiveSheet.Cells(2, 2).Value = "3200 USD"
  FpSpread1.ActiveSheet.Cells(2, 3).Value = "Teacher"
  FpSpread1.ActiveSheet.Cells(3, 0).Value = "Mary"
  FpSpread1.ActiveSheet.Cells(3, 1).Value = "FeMale"
  FpSpread1.ActiveSheet.Cells(3, 2).Value = "2700 USD"
  FpSpread1.ActiveSheet.Cells(3, 3).Value = "Accountant"

 End Sub

 

 


© MESCIUS inc. All rights reserved.