GrapeCity SPREAD for WPF 2.0J
ItemsSource プロパティ (ComboBoxCellType)

セルの内容の生成に使用されるコレクションを取得または設定します。これは依存関係プロパティです。
構文
'Declaration
 
Public Property ItemsSource As IEnumerable
public IEnumerable ItemsSource {get; set;}

プロパティ値

セルの内容の生成に使用されるコレクション。
次のサンプルは ComboBoxCellTypeにデータソースを設定する方法を説明します。
public void SingleColumnBinding()
{
    ComboBoxCellType combo = new ComboBoxCellType();
    combo.ItemsSource = new string[] {"Alice","Robert","Ken","Alen" };
    gcSpreadGrid1[0, 0].CellType = combo;
}
public void MultipleColumnsBinding()
{
    ComboBoxCellType combo = new ComboBoxCellType();
    combo.UseMultipleColumn = true;
    combo.DropDownWidth = 150;
    combo.ContentPath = "FirstName";
    combo.SelectedValuePath = "LastName";
    combo.ItemsSource = new NameList();
    gcSpreadGrid1[0, 0].CellType = combo;
}

public class NameList : ObservableCollection<PersonName>
{
    public NameList()
        : base()
    {
        Add(new PersonName("Alice", "Cather"));
        Add(new PersonName("Robert", "Dinesen"));
        Add(new PersonName("Ken", "Hugo"));
        Add(new PersonName("Alen", "Verne"));
    }
}

public class PersonName
{
    private string firstName;
    private string lastName;

    public PersonName(string first, string last)
    {
        this.firstName = first;
        this.lastName = last;
    }

    public string FirstName
    {
        get { return firstName; }
        set { firstName = value; }
    }

    public string LastName
    {
        get { return lastName; }
        set { lastName = value; }
    }
}
Public Sub SingleColumnBinding()
    Dim combo As New ComboBoxCellType()
    combo.ItemsSource = New String() {"Alice", "Robert", "Ken", "Alen"}
    gcSpreadGrid1(0, 0).CellType = combo
End Sub
Public Sub MultipleColumnsBinding()
    Dim combo As New ComboBoxCellType()
    combo.UseMultipleColumn = True
    combo.DropDownWidth = 150
    combo.ContentPath = "FirstName"
    combo.ItemsSource = New NameList()
    gcSpreadGrid1(0, 0).CellType = combo
End Sub

Public Class NameList
    Inherits ObservableCollection(Of PersonName)
    Public Sub New()
        MyBase.New()
        Add(New PersonName("Alice", "Cather"))
        Add(New PersonName("Robert", "Dinesen"))
        Add(New PersonName("Ken", "Hugo"))
        Add(New PersonName("Alen", "Verne"))
    End Sub
End Class

Public Class PersonName
    Private m_firstName As String
    Private m_lastName As String

    Public Sub New(first As String, last As String)
        Me.m_firstName = first
        Me.m_lastName = last
    End Sub

    Public Property FirstName() As String
        Get
            Return m_firstName
        End Get
        Set(value As String)
            m_firstName = value
        End Set
    End Property

    Public Property LastName() As String
        Get
            Return m_lastName
        End Get
        Set(value As String)
            m_lastName = value
        End Set
    End Property
End Class
参照

ComboBoxCellType クラス
ComboBoxCellType メンバ

 

 


Copyright © 2012 GrapeCity inc. All rights reserved.