Hi all,
I've just discovered a little bug in my code, trying to modify the style of a DateTime UltraGrid's cell. Here is the code:
DefaultEditorOwnerSettings dtsettings = new DefaultEditorOwnerSettings();dtsettings.DataType = typeof(DateTime);dtsettings.MaskInput = "dd/mm/yyyy";DateTimeEditor dteditor = new DateTimeEditor(new DefaultEditorOwner(dtsettings));dteditor.DataFilter = new DateEditorDataFilter(); // this is a custom filter classcell.Editor = dteditor;cell.Style = UltraWinGrid::ColumnStyle.DateWithSpin; // <-- here is the bug
I've found out that the last line in my code has no effect: cell is displayed with a combo instead of a spin control. If I comment out cell.Editor assignment, the spin magically appears.
Do you know if a conflict exists between the two properties (cell.Editor vs. cell.Style)? How can I solve it? Thank you bye! Valentina
That makes sense. the Style property determines the cell editor, so if you set the editor explicitly, Style is ignored. You need to add the spin in the DateTimeEditor.
You're right, I was thinking the same thing... But it seems that dteditor doesn't have a Style property.
It only has SpinButtonDisplayStyle and DropDownButtonDisplayStyleDropDown. Nothing related to showing/hiding time information, while cell.Style property can be set to both DateWithSpin and DateTimeWithSpin values. Is this "time-hiding" work only accomplished by MaskInput settings?
Thanks a lot, bye!
Just a question, why do you use the DateTimeEditor? What's missing in the regular date time editing capabilities of the grid?
The grid receives a string value, and I need to convert it to a DateTime, in order to be displayed by the editor with a calendar control. The value selected by the user must then be converted back to a string with a specific format. To do this, I used a custom DataFilter associated to the editor.
If you just need the data filter, you can use it with the default editor.
Amiram Korach said:If you just need the data filter, you can use it with the default editor.
This will work so long as you want the DataFilter to apply to all of the columns in the grid that use the same editor. The grid will share the same editor amongst multiple columns. I expect that this is based on the Style property, so if you apply the DataFilter to the column.Editor, it will apply to all columns that are using the same editor with the same style.
Another option would be to set up your editor the same way the grid sets up it's internal editor:
dteditor.SpinButtonDisplayStyle = SpinButtonDisplayStyle.OnRight;dteditor.DropDownButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Never;