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.
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?
You can't call an event. You can call the IsItemInList method.
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
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.
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?