作成日: 2026/06/24 最終更新日: 2026/06/24
文書種別
使用方法
詳細
データ連結したコンボボックス型セルを設定した列で、テキストフィルターに値を指定すると、既定では、SelectedValuePathプロパティに設定したフィールドの値を基準してフィルタリングが行われます。この設定はセルの値の格納方法を決定するValueTypeプロパティで変更できます。
表示されている値でフィルタリングを行う場合は、ValueTypeプロパティをComboBoxValueType.Textに設定します。
◎サンプルコード(VB)
表示されている値でフィルタリングを行う場合は、ValueTypeプロパティをComboBoxValueType.Textに設定します。
◎サンプルコード(VB)
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports GrapeCity.Windows.SpreadGrid
Class MainWindow
Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
Dim c As New ComboBoxCellType()
c.ItemsSource = New ProductCollection()
c.ContentPath = "Name"
c.SelectedValuePath = "ID"
'このプロパティを変更します。
c.ValueType = ComboBoxValueType.Text
gcSpreadGrid1.Columns(0).CellType = c
gcSpreadGrid1.CanUserFilterColumns = True
End Sub
End Class
Public Class Product
Implements INotifyPropertyChanged
Private m_id As String
Private m_name As String
Public Property ID() As String
Get
Return m_id
End Get
Set(value As String)
m_id = value
NotifyPropertyChanged("ID")
End Set
End Property
Public Property Name() As String
Get
Return m_name
End Get
Set(value As String)
m_name = value
NotifyPropertyChanged("Name")
End Set
End Property
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Protected Sub NotifyPropertyChanged(propertyName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub
End Class
Public Class ProductCollection
Inherits ObservableCollection(Of Product)
Public Sub New()
Add(New Product() With {.ID = "001", .Name = "あいうえお"})
Add(New Product() With {.ID = "002", .Name = "かきくけこ"})
Add(New Product() With {.ID = "003", .Name = "さしすせそ"})
End Sub
End Class
◎サンプルコード(C#)using GrapeCity.Windows.SpreadGrid;
using System.Collections.ObjectModel;
using System.ComponentModel;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ComboBoxCellType c = new ComboBoxCellType();
c.ItemsSource = new ProductCollection();
c.ContentPath = "Name";
c.SelectedValuePath = "ID";
//このプロパティを変更します。
c.ValueType = ComboBoxValueType.Text;
gcSpreadGrid1.Columns[0].CellType = c;
gcSpreadGrid1.CanUserFilterColumns = true;
}
}
public class Product : INotifyPropertyChanged
{
string id;
string name;
public string ID
{
set { id = value; NotifyPropertyChanged("ID"); }
get { return id; }
}
public string Name
{
set { name = value; NotifyPropertyChanged("Name"); }
get { return name; }
}
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public class ProductCollection : ObservableCollection
{
public ProductCollection()
{
Add(new Product() { ID = "001", Name = "あいうえお" });
Add(new Product() { ID = "002", Name = "かきくけこ" });
Add(new Product() { ID = "003", Name = "さしすせそ" });
}
}