作成日: 2022/03/11 最終更新日: 2022/03/30
文書種別
使用方法
詳細
MultiRowにはページングの機能は用意されておりません。以下の例のようにデータソース側のフィルタ機能などを使用して実現する方法をご検討ください。
[Visual Basic]
[Visual Basic]
Public Class Form1 Private bs As BindingSource Private pageCount As Integer = 10 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' データの作成 Dim dt As New DataTable("TEST") dt.Columns.Add("ID", GetType(Integer)) dt.Columns.Add("ColumnA", GetType(String)) dt.Columns.Add("ColumnB", GetType(String)) dt.Columns("ID").AllowDBNull = False dt.Columns("ID").AutoIncrement = True dt.Columns("ID").Unique = True For i As Integer = 0 To 99 dt.Rows.Add(Nothing, String.Format("A{0}", i), String.Format("B{0}", i)) Next dt.AcceptChanges() bs = New BindingSource(dt, "") bs.Filter = String.Format("ID>={0} AND ID<={1}", 0, pageCount - 1) ' テンプレートの作成 Dim template1 As GrapeCity.Win.MultiRow.Template = GrapeCity.Win.MultiRow.Template.CreateGridTemplate(2) template1.Row.Cells(0).DataField = "ColumnA" template1.Row.Cells(1).DataField = "ColumnB" GcMultiRow1.Template = template1 GcMultiRow1.DataSource = bs GcMultiRow1.AllowUserToAddRows = False End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' 前のページへ移動 Dim pos As Integer = (DirectCast(bs.Current, DataRowView).Row("ID") / pageCount - 1) * pageCount If pos > -1 Then bs.Filter = String.Format("ID>={0} AND ID={0} AND ID
[C#]
public partial class Form1 : Form { BindingSource bs; int pageCount = 10; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // データの作成 DataTable dt = new DataTable("TEST"); dt.Columns.Add("ID", typeof(Int32)); dt.Columns.Add("ColumnA", typeof(String)); dt.Columns.Add("ColumnB", typeof(String)); dt.Columns["ID"].AllowDBNull = false; dt.Columns["ID"].AutoIncrement = true; dt.Columns["ID"].Unique = true; for (int i = 0; i < 100; i++) { dt.Rows.Add(null, string.Format("A{0}", i), string.Format("B{0}", i)); } dt.AcceptChanges(); bs = new BindingSource(dt, ""); bs.Filter = string.Format("ID>={0} AND ID<={1}", 0, pageCount - 1); // MultiRowの設定 GrapeCity.Win.MultiRow.Template template1 = GrapeCity.Win.MultiRow.Template.CreateGridTemplate(2); template1.Row.Cells[0].DataField = "ColumnA"; template1.Row.Cells[1].DataField = "ColumnB"; gcMultiRow1.Template = template1; gcMultiRow1.DataSource = bs; gcMultiRow1.AllowUserToAddRows = false; } private void button1_Click(object sender, EventArgs e) { // 前のページへ移動 int pos = ((int)(bs.Current as DataRowView).Row["ID"] / pageCount - 1) * pageCount; if (pos > -1) { bs.Filter = string.Format("ID>={0} AND ID={0} AND ID