MESCIUS SPREAD for ASP.NET 10.0J
SetModelDataColumn(Int32,String) メソッド

モデルの列インデックス
データソース列の名前
モデル列を指定したデータソース列と連結します。
構文
'Declaration
 
Public Overloads Sub SetModelDataColumn( _
   ByVal column As Integer, _
   ByVal columnName As String _
) 
public void SetModelDataColumn( 
   int column,
   string columnName
)

パラメータ

column
モデルの列インデックス
columnName
データソース列の名前
この例では、DefaultSheetDataModeを作成し、それをスプレッドシートのDataModelに割り当てます。モデルのデータソースを一部のDataTablesに付加し、SetModelDataColumnメソッドが連結するモデルの列とDataSetの列を再配置します。
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If IsPostBack Then Return

    Dim ds As New System.Data.DataSet()
    Dim dm As New FarPoint.Web.Spread.Model.DefaultSheetDataModel()
    FpSpread1.ActiveSheetView.DataModel = dm

    Dim emp As DataTable = New DataTable("Employee")

    Dim lname As DataColumn = New DataColumn("LastName", GetType(System.String))
    Dim fname As DataColumn = New DataColumn("FirstName", GetType(System.String))

    Dim id As DataColumn = emp.Columns.Add("ID",GetType(System.Int32))
    id.AutoIncrement = True
    Dim primarykey As DataColumn() = New DataColumn() { id }
    emp.PrimaryKey = primarykey
    emp.Columns.Add(lname)
    emp.Columns.Add(fname)

    ds.Tables.Add(emp)

    Dim ti As DataRow = emp.NewRow()
    ti(lname) = "Bazemoreland"
    ti(fname)="Ti"
    emp.Rows.Add(ti)

    Dim ginny As DataRow = emp.NewRow()
    ginny(lname) = "Danielson"
    ginny(fname) = "Ginny"
    emp.Rows.Add(ginny)

    Dim bob As DataRow = emp.NewRow()
    bob(lname) = "Morrison"
    bob(fname) = "Bob"
    emp.Rows.Add(bob)

    ds.AcceptChanges()
    dm.DataSource = ds
    dm.SetModelDataColumn(0, "FirstName")
    dm.SetModelDataColumn(2, 0)
End Sub
private void Page_Load(object sender, System.EventArgs e)
{
    if (this.IsPostBack) return;

    System.Data.DataSet ds = new System.Data.DataSet();
    FarPoint.Web.Spread.Model.DefaultSheetDataModel dm = new FarPoint.Web.Spread.Model.DefaultSheetDataModel();
    FpSpread1.ActiveSheetView.DataModel = dm;
    DataTable emp = new DataTable("Employee");
    DataColumn lname = new DataColumn("LastName", typeof(String));
    DataColumn fname = new DataColumn("FirstName", typeof(String));

    DataColumn id = emp.Columns.Add("ID", typeof(Int32));
    id.AutoIncrement = true;
    emp.PrimaryKey = new DataColumn[]{id};
    emp.Columns.Add(lname);
    emp.Columns.Add(fname);

    ds.Tables.Add(emp);

    DataRow ti = emp.NewRow();
    ti[lname] = "Bazemoreland";
    ti[fname] = "Ti";
    emp.Rows.Add(ti);

    DataRow ginny = emp.NewRow();
    ginny[lname] = "Danielson";
    ginny[fname] = "Ginny";
    emp.Rows.Add(ginny);

    DataRow bob = emp.NewRow();
    bob[lname] = "Morrison";
    bob[fname] = "Bob";
    emp.Rows.Add(bob);

    ds.AcceptChanges();
    dm.DataSource = ds;
    dm.SetModelDataColumn(0, "FirstName");
    dm.SetModelDataColumn(2, 0);
}
参照

DefaultSheetDataModel クラス
DefaultSheetDataModel メンバ
オーバーロード一覧

 

 


© MESCIUS inc. All rights reserved.