- Selection color
- DropDownWidth
- Custom filtering
Contact Support
Multiple Columns Support
5 Dec 20234 minutes to read
MultiColumnComboBox control is a ComboBoxAdv control with multiple columns. Multiple columns will be enabled by default. To disable this, set MultiColumn property to false. We can display the headers for the columns using ShowColumnHeader property.
We can bind external data to the MultiColumnComboBox control. Refer DataBinding topic to know more.
Selection color
We can specify the color for the alpha blended selections using AlphaBlendSelectionColor property.
this.multiColumnBoundCombo.MultiColumn = true;
this.multiColumnBoundCombo.ShowColumnHeader = true;
this.multiColumnComboBox1.AlphaBlendSelectionColor = Color.LightBlue;
Me.multiColumnBoundCombo.MultiColumn = True
Me.multiColumnBoundCombo.ShowColumnHeader = True
Me.multiColumnComboBox1.AlphaBlendSelectionColor = Color.LightBlue
DropDownWidth
The DropDownWidth property is used to set the width for the DropDown Popup of MultiColumnComboBox. Please find the code for the same:
this.multiColumnComboBox1.DropDownWidth = 240;
Me.multiColumnComboBox1.DropDownWidth = 240
Fig 1: This screenshot shows the width sets for the DropDown popup of MultiColumnComboBox
Custom filtering
MultiColumnCombobox supports custom filtering through which filter can be applied to all columns. To enable filtering support, AllowFiltering property should be set to true.
this.multiColumnComboBox1.AllowFiltering = true;
Me.multiColumnComboBox1.AllowFiltering = true;
The custom filtering can be applied by assigning a predicate to the Filter property. Based on the filtering condition given, items are filtered and displayed in the dropdown.
public Filtering()
{
//Allowing filter
this.multiColumnComboBox1.AllowFiltering = true;
// Event triggered while MultiColumnCombobox's Text changed
this.multiColumnComboBox1.TextChanged += MultiColumnComboboxTextBox_TextChanged;
}
private void MultiColumnComboboxTextBox_TextChanged(object sender, EventArgs e)
{
// The filter criteria can be given in the FilterRecords method which can be assigned to Filter property.
this.multiColumnComboBox1.Filter = FilterRecords;
}
public bool FilterRecords(object o)
{
var item = o as OrderInfo;
if (item != null)
{
if(item.ProductName.Equals(this.multiColumnComboBox1.TextBox.Text))
return true;
}
return false;
}
Public Sub New()
//Allowing filter
Me.multiColumnComboBox1.AllowFiltering = True
// Event triggered while MultiColumnCombobox's Text changed
Me.multiColumnComboBox1.TextChanged += MultiColumnComboboxTextBox_TextChanged
End Sub
Private Sub MultiColumnComboboxTextBox_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
// The filter criteria can be given in the FilterRecords method which can be assigned to Filter property.
Me.multiColumnComboBox1.Filter = FilterRecords
End Sub
Public Function FilterRecords(ByVal o As Object) As Boolean
Dim item = TryCast(o, OrderInfo)
If item IsNot Nothing Then
If item.ProductName.Equals(Me.multiColumnComboBox1.TextBox.Text) Then Return True
End If
Return False
End Function
NOTE
If AllowFiltering is enabled and the filtering is not set or it is set to null, the default filtering will be applied.
Default filtering uses DisplayMember as Column withStartWith
condition.