Hi all, I am trying to get Eto to show the drop down list as the user starts typing (on focus). At the moment the user must click on the arrow for the drop down to show. Is there a way to activate it programmatically? If not please confirm it is not possible, or my OCD brain will explode
I can see there are events for DropDownClose and DropDownOpening, but no method or property such as DropDown() or DoppedDown.
Here is my code
public class TypableCombo : Form
{
public TypableCombo()
{
Title = "Eto.Forms ComboBox Example";
ClientSize = new Size(400, 300);
var comboBox = new ComboBox { AutoComplete = true };
var items = new List<string> { "Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape" };
comboBox.DataStore = items;
comboBox.TextChanged += (sender, e) =>
{
var text = comboBox.Text;
comboBox.DataStore = items.Where(i => i.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0).ToList();
};
comboBox.GotFocus += (sender, e) =>
{
//I want the drop down list to appear on focus
};
comboBox.KeyDown += (sender, e) =>
{
if (e.Key == Keys.Escape)
{
comboBox.Text = string.Empty;
comboBox.DataStore = items;
}
else if (e.Key == Keys.Enter)
{
ValidateComboBox(comboBox, items);
}
};
comboBox.LostFocus += (sender, e) =>
{
ValidateComboBox(comboBox, items);
};
Content = new StackLayout
{
Padding = 10,
Items =
{
new Label { Text = "Start typing to filter the list:" },
comboBox
}
};
}
private void ValidateComboBox(ComboBox comboBox, List<string> items)
{
if (items.Contains(comboBox.Text))
{
comboBox.TextColor = Colors.Black;
}
else
{
comboBox.TextColor = Colors.Red;
comboBox.Focus();
}
}
}