コントロール上の行および列数はSheetViewクラスのRowCountプロパティまたはColumnCountプロパティによって定義されますが、同クラスメンバであるAddRowsメソッドやAddColumnsメソッド呼び出し等により、任意の箇所に追加することができます。
|
private void Form1_Load(object sender, System.EventArgs e) { //行数を3にします fpSpread1.ActiveSheet.RowCount = 3; fpSpread1.ActiveSheet.Columns[0].CellType = new FarPoint.Win.Spread.CellType.TextCellType(); fpSpread1.ActiveSheet.SetText(0, 0, "1行目"); fpSpread1.ActiveSheet.SetText(1, 0, "2行目"); fpSpread1.ActiveSheet.SetText(2, 0, "3行目"); fpSpread1.ActiveSheet.SetColumnWidth(0, 90); } private void button1_Click(object sender, System.EventArgs e) { //2行目に1行を追加します fpSpread1.ActiveSheet.AddRows(1, 1); fpSpread1.ActiveSheet.SetText(1, 0, "追加された行"); } private void button2_Click(object sender, System.EventArgs e) { //2列目に1列を追加します fpSpread1.ActiveSheet.AddColumns(1, 1); fpSpread1.ActiveSheet.SetText(0, 1, "追加された列"); }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load '行数を3にします FpSpread1.ActiveSheet.RowCount = 3 FpSpread1.ActiveSheet.Columns(0).CellType = New FarPoint.Win.Spread.CellType.TextCellType FpSpread1.ActiveSheet.SetText(0, 0, "1行目") FpSpread1.ActiveSheet.SetText(1, 0, "2行目") FpSpread1.ActiveSheet.SetText(2, 0, "3行目") FpSpread1.ActiveSheet.SetColumnWidth(0, 90) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '2行目に1行を追加します FpSpread1.ActiveSheet.AddRows(1, 1) FpSpread1.ActiveSheet.SetText(1, 0, "追加された行") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click '2列目に1列を追加します FpSpread1.ActiveSheet.AddColumns(1, 1) FpSpread1.ActiveSheet.SetText(0, 1, "追加された列") End Sub