Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
UltraCombo ignores case when selecting values with keyboard
posted

When a value occurs twice in a dropdown, but with different casing, it is impossible to select the second one by typing the value. The UltraCombo will always select the first one - regardless of the case.

Here's an example (Windows Forms, C#, .NET 4.x):

public class Form1 : Form
{
	public Form1()
	{
	    InitializeComponent();
	
	    ultraCombo.DataSource = GetDataTable();
	}
	
	private static DataTable GetDataTable()
	{
	    var dataTable = new DataTable();
	
	    dataTable.Columns.Add("Code", typeof(string));
	    dataTable.Columns.Add("Description", typeof(string));
	
	    dataTable.Rows.Add("a", "lowercase"); // Selectable with a or A
	    dataTable.Rows.Add("B", "UPPERCASE"); // Selectable with b or B
	    dataTable.Rows.Add("c", "lowercase"); // Selectable with c... or C
	    dataTable.Rows.Add("C", "UPPERCASE"); // Cannot select with keyboard
	
	    return dataTable;
	}
	
	private void UltraCombo_RowSelected(object sender, Infragistics.Win.UltraWinGrid.RowSelectedEventArgs e)
	{
	    selectedLabel.Text = e.Row != null ? $@"{e.Row.Cells["Code"].Value} {e.Row.Cells["Description"].Value}" : null;
	}
	
	private void InitializeComponent()
	{
	    this.ultraCombo = new Infragistics.Win.UltraWinGrid.UltraCombo();
	    this.selectedLabel = new System.Windows.Forms.Label();
	    ((System.ComponentModel.ISupportInitialize)(this.ultraCombo)).BeginInit();
	    this.SuspendLayout();
	    // 
	    // ultraCombo
	    // 
	    this.ultraCombo.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.None;
	    this.ultraCombo.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal;
	    this.ultraCombo.Location = new System.Drawing.Point(8, 8);
	    this.ultraCombo.Name = "ultraCombo";
	    this.ultraCombo.RowSelected += new Infragistics.Win.UltraWinGrid.RowSelectedEventHandler(this.UltraCombo_RowSelected);
	    // 
	    // selectedLabel
	    // 
	    this.selectedLabel.Location = new System.Drawing.Point(8, 40);
	    this.selectedLabel.Name = "selectedLabel";
	    // 
	    // Form1
	    // 
	    this.Controls.Add(this.ultraCombo);
	    this.Controls.Add(this.selectedLabel);
	    this.Name = "Form1";
	    this.Text = "UltraCombo";
	    ((System.ComponentModel.ISupportInitialize)(this.ultraCombo)).EndInit();
	    this.ResumeLayout(false);
	    this.PerformLayout();
	}
}

private Infragistics.Win.UltraWinGrid.UltraCombo ultraCombo;
private System.Windows.Forms.Label selectedLabel;


Typing "a" selects the first item
Typing "A" (shift + a) selects the first item

Typing "b" selects the second item
Typing "B" (shift + b) selects the second item

Typing "c" selects the third item
Typing "C" (shift + c) selects... the third item whereas I expected the fourth

Changing the order in which c and C get added to the datatable, switches behavior. In that case it's always uppercase C that gets selected regardless typing "c" or "C"

The a-A and b-B cases are understandable and probably convenient for the user. The c-C case is wrong in my opinion. The UltraCombo should only try to select the first best match if no exact match was found. Especially because AutoCompleteMode is set to None.



My question: Is there a way to make the UltraCombo properly case-sensitive? It's okay if the a-A and b-B cases become case-sensitive too.

I found a topic that discusses exactly the same problem:

UltraCombo is ignoring case when selecting values (6 years ago)

Sadly the posted solution does not work for me. AutoCompleteMode is already None, CharacterCasing is Normal and adding "dataTable.CaseSensitive = true" to the example above makes no change.