Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Text in the UltraComboEditor disappeared when it lose focus
posted

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

 

Parents Reply Children