Home › Forums › WinForms controls › Xceed Grid for WinForms › Auto complete on combo boxes
-
AuthorPosts
-
#12850 |
Hey Everyone,
I was wondering if the combo boxes that came with this amazing Grid 2.0 support Autocomplete. That is when you type in the combo box it lookups available selections that match your text. Now, I’ve noticed that it does the first character I type, any way to extend that to every character? And can the combo box be told to drop down when the user starts typing in it?
Any suggestions / help is greatly appreciated
ACanadian
Imported from legacy forums. Posted by ACanadian (had 7609 views)
I haven’t tried it yet, but I know that GridComboBox is derived from ComboBox, which has an attribute DropDownStyle. Try setting it the ComboBoxStyle.DropDown.
Imported from legacy forums. Posted by Tommy (had 268 views)
Hey thanks, that was exactly what the problem was.
Now here is another question for you.
Can an event be created on the combobox so that when the user starts typing in the field, the combo box automagically drops down?
I can do this with regular combo boxes by setting DroppedDown to true on the key press event.
Howerver when I assign the key press event to the combo box in the grid, nothing happens?
Just wondering,
ACanadian
Imported from legacy forums. Posted by ACanadian (had 330 views)
Have you assigned the key press event before assigning it as CellEditor, or after?
Imported from legacy forums. Posted by Tommy (had 198 views)
I have not been able to get auto complete to work with the gridcombobox. Simply changing the dropdownstyle to dropdown does not seem to do it for me. Can anyone help me out.
Imported from legacy forums. Posted by destraht (had 322 views)
combo.DropDownStyle = ComboBoxStyle.DropDownList;
Not
combo.DropDownStyle = ComboBoxStyle.DropDown;
Imported from legacy forums. Posted by Asbury (had 412 views)
combo.DropDownStyle = ComboBoxStyle.DropDownList;
does not allow you to autocomplete more than the first character. I’m not interested in building another AutoComplete control. Xceed or anyone else, do you have one?
Imported from legacy forums. Posted by Asbury (had 382 views)
I have developed one, but it doesn’t inherit from ComboBox. It’s a custom control (inherits from Control), that uses a TextBox, a Button, and a Form with a ListBox (the dropdown part). And you can use it as a CellViewer/CellEditor.
I have to say, it’s a complicated thing to make. I can’t give you the control in its current form, because it’s specifically designed to be used in our framework (our company creates custom .NET applications). The naming scheme of our code is also a bit weird for outsiders, so it wouldn’t fit in your application.
But I’ll try to create a new version, that can be used externally.Imported from legacy forums. Posted by Tommy (had 297 views)
There is another option for the GridComboBox, AutoCompleteMode. This can be set to: None, Append, Suggest, SuggestAppend.
This will give you traditional autocomplete.
I have found an issue with this tough. The following code sets up a drop down list and autocompletion:
void EnteringEdit(object sender, Xceed.Grid.EnteringEditEventArgs e) {
Xceed.Grid.Editors.GridComboBox box = new Xceed.Grid.Editors.GridComboBox();
box.DropDownStyle = ComboBoxStyle.DropDown;
box.AutoCompleteMode = AutoCompleteMode.None;
box.AutoCompleteSource = AutoCompleteSource.CustomSource;
foreach (string s in stringList) { // Definted elsewhere
box.Items.Add(s);
}
box.AutoCompleteCustomSource.AddRange(sa);
}
}e.CellEditor = box;
}If I select the drop down menu and then hit enter, the value in the cell is wiped out and set to “”.
thanks,
kiwiImported from legacy forums. Posted by kiwi (had 384 views)
This feature is a new feature of the basic TextBox and ComboBox in .NET 2.0. And GridComboBox inherits from ThemedComboBox, which inherits from ComboBox. It doesn’t exist in .NET 1.1.
Imported from legacy forums. Posted by Tommy (had 348 views)
I got some auto complete functions working by hacking up some code that was avaiable.
so far seems to work ok.
also setDim GridComboBox2 As EEC.Custom.Windows.Forms.GridCompletionComboBox = New EEC.Custom.Windows.Forms.GridCompletionComboBox
GridComboBox2.DropDownStyle = ComboBoxStyle.DropDown
just make a new library file from the following
//Copied from Genghis.Windows.Forms.CompletionCombo
//Modified for use with Xceed gridcomboboxusing System;
using System.Diagnostics;
using System.Windows.Forms;
using System.ComponentModel;
using Xceed.Grid;
using Xceed.Grid.Editors;namespace EEC.Custom.Windows.Forms
{
/// <summary>
/// Combo Box that should do an autocomplete when typing.
/// </summary>
public class GridCompletionComboBox : GridComboBox
{
public event System.ComponentModel.CancelEventHandler NotInList;[Category(“Behavior”)]
public bool LimitToList
{
get {return _limitToList;}
set { _limitToList = value;}
}protected virtual void OnNotInList(System.ComponentModel.CancelEventArgs e)
{
if (NotInList != null)
NotInList.Invoke(this, e);
}protected override void OnValidating(System.ComponentModel.CancelEventArgs e)
{
if (_limitToList)
{
int pos = FindStringExact(Text);
if (pos == -1)
OnNotInList(e);
else
this.SelectedIndex = pos;
}
base.OnValidating(e);
}protected override void OnKeyDown(KeyEventArgs args)
{
_autoComplete = args.KeyCode != Keys.Delete && args.KeyCode != Keys.Back;
base.OnKeyDown(args);
}protected override void OnTextChanged(EventArgs args)
{
if(_autoComplete)
{
string textEntered = Text;
int index = FindString(textEntered);
if (index >= 0 )
{
_autoComplete = false;
SelectedIndex = index;
_autoComplete = true;
Select(textEntered.Length, Text.Length);
}
}
base.OnTextChanged(args);
}
private bool _autoComplete = true;
private bool _limitToList = true;
}
}Imported from legacy forums. Posted by Vol (had 8014 views)
-
AuthorPosts
- You must be logged in to reply to this topic.