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