Hi,
i have a UltraWinGrid in which there is a cell composed of UltraTextEditor. in this cell, i want to enable user to select the items in a CheckedListBox, and then show the items in the cell. it would work like following,
The below is some code,
CheckedListBox listView = new CheckedListBox();
DropDownEditorButton dropDown = new DropDownEditorButton();
UltraTextEditor textEditor = new UltraTextEditor();
textEditor.Enabled = false;
textEditor.ReadOnly = true;
textEditor.ContextMenu = null;
dropDown.Control = listView;
textEditor.ButtonsRight.Add(dropDown);
listView.Sorted = true;
listView.ContextMenu = null;
listView.CheckOnClick = true;
listView.Width = cell.Width;
string[] items = .....
listView.Items.AddRange(items);
cell.EditorControl = textEditor;
...
cell.Value = selectedItems;
So my problem is, after the selected items showed in the cell, i don't want the user could edit them or type anything in the cell, i make it work by capturing the keyboard events. but the user could still right click on the showed text to pop-up the contextmenu to do "cut" or sth else. so how do i disable this?
thanks.
Hi louvie,
No, I don't think there is any way to do that. The multiple-selection feature will always return a list, there's no way to make it return a comma-delimited string like you have here.
Maybe you could hide the "real" column which contains a single string and use an unbound column whose datatype is List<string> for display to the user. You could then use events of the grid to convert the string to a list (InitializeRow) and the list to a String (BeforeRowUpdate).
Hi, Mike
Really appreciate your reply. i think you are right, i attached the data of string not list<string> or string array to the cell, this is probably the root cause.
so is there any way to return a string not a list of objects? The feature i want is,
Suppose there are four items( USA, England, China, France) in the dropdown list of the UltraComboEditor, when the user select China and France, the value and the display text in the cell is
"China, France", and this string will not be parsed to string[2]{"China", "France"} or something like this.
i want to pass the whole string to the data instance i binded to this cell.
For your concern about attaching the editor to a single cell, that's because the items in the UltraComboEditor are varied as the user input different things in the cells before the current.
Regards,
louvie
What is the DataType of the column to which you are attaching the editor? My guess is that the column's data type cannot handle what the editor it trying to return, which is a list of objects.
Also... why are you attaching the editor to a single cell? Do you need to do this only for certain cells? If not, it's much more efficient to set the Editor on the column.
HI, Mike
Thank you for your answer.
The version i am using is NetAdvantage 10.3.20103.1000.
I am trying UltraComboEditor as you suggested, but met another problem "Unable to updateData", it
throws an exception said "Value in the editor is not valid.", the issue is similar to this thread: http://community.infragistics.com/forums/t/48458.aspx
But i don't think the solution proposed in that thread could make it work.
I add UltraComboEditor to the grid in the following Event handler,
private void ultraGrid1_BeforeCellActivate(object sender, IWG.CancelableCellEventArgs e)
{
e.Cell.Column.Style = IWG.ColumnStyle.DropDownList;
UltraComboEditor editor = new UltraComboEditor();
editor.CheckedListSettings.CheckBoxStyle = Infragistics.Win.CheckStyle.CheckBox;
editor.CheckedListSettings.ItemCheckArea = Infragistics.Win.ItemCheckArea.CheckBox;
editor.CheckedListSettings.EditorValueSource = Infragistics.Win.EditorWithComboValueSource.CheckedItems;
editor.CheckedListSettings.ListSeparator = ",";
editor.ValueList = this.ultraGrid1.DisplayLayout.ValueLists[propertyName];
cell.EditorComponent = editor;
}
It pops up the checkedlist box successfully when i click the cell, but when i try to select one more item, it will throw the exception mentioned above.
So could you give any hints, thank you.
What version of the controls are you using?
The latest version has built-in support for multiple selection using the UltraComboEditor so you do not need to use a ListView.
If you want the user to only choose from the list and not type, then you should set the column's Style to DropDownList.