Hi IG,
I have this code:
private void _grid_KeyDown(object sender, KeyEventArgs e){ //delete key = clear the current cell if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back) { if (0 == (_grid.CurrentState & UltraGridState.InEdit)) if (_grid.ActiveCell != null) if (_grid.ActiveCell.Value is CellClass) (_grid.ActiveCell.Value as CellClass).Clear(); }}
The problem is, the cell is not refreshed/repainted until you move the mouse over, or scroll/resize the column, etc. Cell is displayed as string, and CellClass has ToString() via IConvertible.
I tried adding BeginInvoke() around -> no success.I tried _grid.ActiveCell.Refresh() -> no success.I tried _grid.Invalidate(_grid.ActiveCell.GetUIElement().Rect) -> no success.I tried reassign the same value to the ActiveCell -> no success.I debugged, and the ActiveCell.Text immediately changes to "" after calling Clear().
What could be the problem? Thanks.
Hello Michael,
Thank you for contacting Infragistics Support.
In order to give you my best possible solution for your issue can you please give me a little more information regarding your case:
1) How you have implemented your CellClass?
2) Have you implemented INotifyPropertyChangedinterface in your CellClass?
3) Did you call the PropertyChanged event in your custom CellClass?
It will help if you can provide a small, isolated sample application that demonstrates the behavior you are experience.
Waiting for your feedback.
Hi Milko,
Thanks for your help.
This is how grid is used:
class CellClass : IConvertible{ public String DisplayValue = ""; public MyClass RealValue = null; public CellClass(String displayValue, MyClass realValue) { DisplayValue = displayValue; RealValue = realValue; } public SetValue(String displayValue) { RealValue = Parse(displayValue); DisplayValue = RealValue.AsString(); }
#region IConvertible Members public object ToType(Type conversionType, IFormatProvider provider) { return Convert.ChangeType(DisplayValue, conversionType); } public TypeCode GetTypeCode() { return TypeCode.Object; } public string ToString(IFormatProvider provider) { return DisplayValue; } //rest of IConvertible just throw new NotImplementedException(); #endregion internal void Clear() { DisplayValue = ""; RealValue = null; }}void BuildGrid(){ _gridSource.Rows.Clear(); _gridSource.Band.Columns.Clear(); for (x = ....) { UltraDataColumn col = _gridSource.Band.Columns.Add(name[x], typeof(Object)); UltraGridColumn gridCol = _grid.DisplayLayout.Bands[0].Columns[_grid.DisplayLayout.Bands[0].Columns.Count - 1]; gridCol.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Edit; }}void LoadData(){ List<object> row = new List<object>(); foreach (......) { row.Add(new CellClass ("", new MyClass(...))); } _gridSource.Rows.Add(row.ToArray());}
The principal is that, we are storing own class in every cell of the grid (Object / CellClass), but displaying them as String.
When user edits cells, we are parsing the new String value, and converting it to CellClass.