Hello Terry,
I believe that the CB43883 (grid rowcellstyle) Support Center issue will be helpful in this situation. Please let me know whether the issue is resolved.
Thanks,
Anatol
Your sample does not solve my issue for two reasons:
1) I'm running in a near real-time environment. I don't want background threads running and waking up occasionally to see if the cells need to be restyled. I prefer them to be restyled when the user changes a cell value.
2) Every time LayoutChanged is called, it closes the current cell editor. I won't inflict that on my user. In your example, I cannot enter numbers with multiple digits without them getting wiped out.
So apparently, there is no way to restyle the grid cells while keeping a cell editor open and active? I'll have to teach my user to complete an entry and then click outside the cell to see the grid restyled.
Hello Terry,
Thank you for your feedback. Now I see that your situation differs from the one described in the CB43883 issue. The cause of the problem is that editors' values are not posted to the GridControl datasource immediately after being changed. I've created a sample project to demonstrate how to change this behavior. Please let me know whether this solution meets your requirements.
Thanks,
Anatol
Where would this go? I don't quite understand what it's doing, but I tried it as the first line of code in ActiveEditor_EditValueChanged. That doesn't make any difference.
Though it didn't seem to make sense, I also tried it as the first line of code in bandedGridView1_ShownEditor and that excepted on a null reference in OldEditValue.
This works as the first code in ActiveEditor_EditValueChanged:
if (bandedGridView1.ActiveEditor.OldEditValue.Equals("-") ||
bandedGridView1.ActiveEditor.EditValue.Equals("-") ||
bandedGridView1.ActiveEditor.OldEditValue.Equals("+") ||
bandedGridView1.ActiveEditor.EditValue.Equals("+"))
{
return;
}
Is that overkill?
Hello Terry,
Sorry for the misunderstanding. When you wrote that you are experiencing difficulties with entering negative numbers, I thought that you were using the SpinEdit editor for the numeric column. However, from your response, I see that you are using a simple TextEdit without a mask. In this case, your solution is acceptable (with some modifications), but from my point of view, it is better to use the following code:
However, I recommend that you apply the numeric mask for the numeric field. In this case, the user input will be restricted, and the EditValue will always be handled as the numeric type, so you won't have to care about the described situation. I've modified my sample to demonstrate this approach. For additional information, please refer to the Mask Type: Numeric help topics.[C#]void ActiveEditor_EditValueChanged(object sender, EventArgs e) { TextEdit editor = gridView1.ActiveEditor as TextEdit; int selectionStart = 0, oldValue = 0, newValue = 0; if (editor != null) { if (gridView1.FocusedColumn.ColumnType == typeof(Int32)) { oldValue = (Int32)editor.OldEditValue; if (editor.EditValue is Int32) { newValue = (Int32)editor.EditValue; } else { if (!Int32.TryParse(editor.EditValue as String, out newValue)) { return; } } if (oldValue == newValue) return; } selectionStart = editor.SelectionStart; } gridView1.PostEditor(); gridView1.LayoutChanged(); gridView1.ShowEditor(); if (editor != null) { editor.SelectionStart = selectionStart; editor.SelectionLength = 0; } } public class DataSourceClass { ... private int _Value; public int Value { get { return _Value; } set { if (_Value != value) { _IsChanged = true; } _Value = value; } } }
Thanks,
Anatol
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.