Hi, Mike
I am trying the method you proposed in the post http://community.infragistics.com/forums/p/55961/287029.aspx#287029, "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)."
During the test, i found the text in the ultraComboEditor disappeared when the cell lose focus, the cell changed to blank. i pasted some code here,
private void ultraGrid1_InitializeLayout(object sender, IWG.InitializeLayoutEventArgs e)
{
// override the backgroud color of the active cell.
this.ultraGrid1.DisplayLayout.Override.ActiveRowCellAppearance.BackColor = Color.White;
this.ultraGrid1.DisplayLayout.Override.ActiveRowCellAppearance.ForeColor = Color.Black;
this.Columns[StrValue].Hidden = true; // hide the real bound column
this.Columns.Add(m_fakeColName, "NewValue"); // add a fake column
this.Columns[m_fakeColName].DataType = typeof(List<string>);
}
// fill the cell with different controls based on the cell content before the active cell
private void ultraGrid1_BeforeCellActivate(object sender, IWG.CancelableCellEventArgs e)
if (e.Cell.Column.Key.Equals(m_fakeColName))
string property = e.Cell.Row.Cells[StrProperty].Value.ToString();
if (string.IsNullOrEmpty(property)) return;
if (m_propertyAttriDic[property].CtrlStyle == ControlStyle.CheckedListBox)
Columns[m_fakeColName].Style = IWG.ColumnStyle.DropDownList;
if (cell.EditorComponent == null)
UltraComboEditor editor = new UltraComboEditor();
editor.CheckedListSettings.CheckBoxStyle = Infragistics.Win.CheckStyle.CheckBox;
editor.CheckedListSettings.ItemCheckArea = Infragistics.Win.ItemCheckArea.Item;
editor.CheckedListSettings.EditorValueSource = Infragistics.Win.EditorWithComboValueSource.CheckedItems;
editor.CheckedListSettings.ListSeparator = new string( FilterHelper.Seperators);
editor.ValueList = this.ultraGrid1.DisplayLayout.ValueLists[propertyName];
this.Columns[m_fakeColName].EditorComponent = editor;
private void ultraGrid1_BeforeRowUpdate(object sender, Infragistics.Win.UltraWinGrid.CancelableRowEventArgs e)
List<string> values = e.Row.Cells[m_strFakeValueCol].Value as List<string>;
if (values != null)
string newValue = string.Empty;
foreach (string value in values)
newValue += value;
if (values.IndexOf(value) < values.Count - 1)
newValue += new string(FilterHelper.Seperators);
m_filterList[e.Row.Index].Value = newValue;
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
string value = e.Row.Cells[StrValue].Value as string;
if (!string.IsNullOrEmpty(value))
e.Row.Cells[m_strFakeValueCol].Value = new List<string>(value.Split(FilterHelper.Seperators));
Thanks in advance.
Regards,
louvie
Hi louvie,
Just to clarify, you are dropping down the list and checking some items, then when you leave the cell, it goes blank?
This could be because InitializeRow is firing again after you leave the cell. So you probably have to add a check for e.ReInitialize == false in your InitializeRow event. Assuming that the data in your "real" column won't be changed directly in the data source or in the grid via code, you only need to populate your unbound cell the first time the row Initializes.
If that doesn't help, then can you put together a small sample project that demonstrates what's happening so I can check it out?
It's hard to tell much from code snippets like this.
Could you pls take a look at the attached project ?
in the winform, i add two buttons "+" and "-", button "+" is for adding new rows while button "-" is for deleting the current active row. On the right side, it is a ultragrid binded with Bindinglist<DataItem>.
the issue could be produced by,
0> run the project
1> click "+" to add a new row;
2> click the Property column in the new added row and select "Language"
3> click the condition column and select "is any of"
4> click the value column and check "English" and "Chinese", the two strings are displayed in the cell correcltly
5> click any other cell or place to make the Value colum lose focus, the content in the value column will disappeared.
Okay, I took a look at your sample and it was a struggle, but I figured out how to make it work.
There are two small changes I made.
Apparently, the multi-select functionality only work with a column whose DataType is List<object>. It will not work with List<string>.
I'm not sure why this is - it might be a bug or an oversight. I'm going to ask Infragistics Developer Support to write it up so we can look into it.
The second issue is that the multi-select functionality does not work in DropDownList style. So the user must be able to type in to the list, you cannot force them to only select from it.
Again, this seems like an odd limitation and I'm not sure if this is intentional or a bug, but I will ask Dev Support to look into this, also.
Anyway, I attached a modified version of your sample here that now works correctly. I commented my changes with the word "IGMikeS", so you can find them easily by searching for that string.
Hi,
I am using itemnotinList event to check if the item is in list when user types in something for both ulreacombo and ultracomboeditor.
But this is validating only when we lost the focus from one control to other. its not validating when the focus is not same combo box.
I need a way that when user types in something that one is not in liat and some "SAVE" button it first validating that combo box.
Currently it wors only on save if i give a focus to smoe other control.
But if i don't give a focus to some otheer control it ill throw an exception because that value is not there in list.
If you are clicking on a button that doesn't get focus (and therefore the combo does not lose focus), then the control has no way to know that anything happened.
In that case, you could call the IsItemInList method on the control to see if the current entry is valid.
So that means on SAVE i need to call itemnotinlist event?
Is your Save button on the base form? If not, then there is no way to handle this on a base form. If so, then all you have to do is find the form and call ValidateChildren on it.
Thanks for your reply.
In my application, i have lot of forms and i need to implement in on all forms.
We have base form and we inherits all forms from the base form.
So can you suggest me some idea on base form level with some sample code please?
Yes, I understand. So once again, when you click your save button, you can call the IsItemInList method to determine if the item is on the list.
Another option would be to call the ValidateChildren method of the form to force validation of the control(s) without losing focus.
Here in my code i am doing like this.
Private Sub ucCombo_ItemNotInList(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs) Handles cmbAssignTo.ItemNotInList
Dim ucCombo As Infragistics.Win.UltraWinGrid.UltraCombo = CType(sender, Infragistics.Win.UltraWinGrid.UltraCombo)
Try
ucCombo.Text =""
e.RetainFocus =False
Catch ex As Exception
End Try
But this works only i lost the focus. if focus is still on combo and trying to save will throw an exception.
End Sub
You can't call an event. You can call the IsItemInList method.