mobilecontrols-devexpress-dot-xamarinforms-dot-datagrid-075b5612.md
A grid column used to display and edit text values. The column displays a drop-down list that contains available values.
Namespace : DevExpress.XamarinForms.DataGrid
Assembly : DevExpress.XamarinForms.Grid.dll
NuGet Package : DevExpress.XamarinForms.Grid
public class ComboBoxColumn :
PickerColumn
The ComboBoxColumn is a column in the DataGridView that displays available values in a drop-down list.
The ItemsSource collection contains values that users can select in the drop-down list. If this collection contains business objects, use the following properties to describe the business object’s data fields:
Use the following properties to adjust column settings:
You can configure the following options related to all types of grid columns:
Use the following properties to sort and group data in the grid, and calculate cell values based on expressions:
The grid stores columns in the DataGridView.Columns collection. Depending on the AutoGenerateColumnsMode option, the grid automatically generates columns based on the bound data source, or you can add columns to the grid and associate them with data fields manually. See the following help topic for an example: Create Columns for Different Data Types.
The example below uses the ComboBoxColumn to display available values in the drop-down list when a user types in a cell.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxg="http://schemas.devexpress.com/xamarin/2014/forms/datagrid"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=netstandard">
<dxg:DataGridView ItemsSource="{Binding Path=Employees}"
EditorShowMode="Tap">
<dxg:DataGridView.Columns>
<!-- Other columns here. -->
<dxg:ComboBoxColumn FieldName="JobTitle"
EditorFilterComparisonType="CurrentCultureIgnoreCase"
EditorFilterMode="StartsWith"
IsEditorFilterEnabled="True">
<dxg:ComboBoxColumn.ItemsSource>
<scg:List x:TypeArguments="x:String">
<x:String>Chief Executive Officer</x:String>
<x:String>Chief Technology Officer</x:String>
<x:String>Network Administrator</x:String>
</scg:List>
</dxg:ComboBoxColumn.ItemsSource>
</dxg:ComboBoxColumn>
<!-- Other columns here. -->
</dxg:DataGridView.Columns>
</dxg:DataGridView>
</ContentPage>
using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;
public partial class EditingView : ContentPage {
public EditingView() {
InitializeComponent();
BindingContext = new Repository(300);
}
}
public class Repository {
public ObservableCollection<Employee> Employees { get; private set; }
public Repository(int rowsCount) {
Employees = new ObservableCollection<Employees>();
for (int i = 0; i < rowsCount; i++) {
Employees.Add(new Employee());
}
}
}
public class Employee {
public string FullName { get; set; }
public string JobTitle { get; set; }
}
In the example below, the ComboBoxColumn is bound to a data field that contains integer values. To display strings instead of integers in the drop-down list, the example uses a business object that combines strings with integers. The DisplayMember and ValueMember properties specify data fields that contain displayed strings and actual integer values.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxg="http://schemas.devexpress.com/xamarin/2014/forms/datagrid">
<dxg:DataGridView x:Name="dataGridView"
ItemsSource="{Binding Path=Employees}"
EditorShowMode="Tap">
<dxg:DataGridView.Columns>
<!-- Other columns here. -->
<dxg:ComboBoxColumn FieldName="Job"
ItemsSource="{Binding Jobs}"
DisplayMember="Title"
ValueMember="Id"
IsEditorFilterEnabled="True">
</dxg:ComboBoxColumn>
<!-- Other columns here. -->
</dxg:DataGridView.Columns>
</dxg:DataGridView>
</ContentPage>
using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;
public partial class EditingView : ContentPage {
public EditingView() {
InitializeComponent();
BindingContext = new Repository(300);
}
}
public class Repository {
public ObservableCollection<Employee> Employees { get; private set; }
public ObservableCollection<Job> Jobs { get; private set; }
public Repository(int rowsCount) {
Employees = new ObservableCollection<Employees>();
Jobs = new ObservableCollection<Job>();
for (int i = 0; i < rowsCount; i++) {
Employees.Add(new Employee());
Jobs.Add(new Job());
}
}
}
public class Employee {
public string FullName { get; set; }
public int Job { get; set; }
}
public class Job {
public int Id { get; set; }
public string Title { get; set; }
}
Object GridColumn TextColumnBase PickerColumn ComboBoxColumn
See Also