I have a datetime column, so when the user can enter a date using the calendar pop up. How can I set a default value for the calendar that is being poped?
Is it possible to have control over that calendar?
Hi,
The selected date in the dropdown is determined by the current Value of the cell in the grid. You might be able to change the selected value inside the AfterCellDropDown event of the grid, but this would also alter the value of the cell, just as though the user had selected a value, so I don't think that's what you want.
Correction: There is no AfterCellListDropDown event. I was thinking of BeforeCellListDropDown. But that won't work, because it fires before the list is dropped down and the selected item has not yet been set. So there's no way to do this.
So the only way is to set the cell value to a default value on a beforcelldropdown event maybe ?
Okay, I'm confused.
Do you want to set the default value of the DropDown? Or the default value of the cell itself? It seems to me that it would be weird to set the default value of the dropdown to something different than the cell's actual value, but that appears to be what you are asking.
If you want to set the default value of the cell, then you could do that in any number of ways. If the column is unbound, you could use the DefaultCellValue property on the column. If it's bound, you could fill in values in the data source. Or you could use the InitializeRow event and set the value only when e.ReInitialize is false.
If you really want to set the default selected value on the dropdown to something other than the value of the cell, then I don't see any way to do that. I suppose if you wanted to, you could try creating your own dropdown control. You could use UltraTextEditor or UltraNumericEditor, add an EditorDropDownButton to it with a MonthCalendar control on it. That way you could control the selection yourself. But I'm not sure how you would prevent the cell value from changing when you set the selected item on the MonthCalendar, but still set the cell value when the user chooses a value.
yeah i just want to set some value by default if there's no value in the cell. so it's like a default value. but the default value is case by case.
But if I set the value into the cell,the value will appear in the cell right? But I dont want it to appear.
The behavior is really, there's no value in the cell. The user will want to specify a date, the calendar pop-ups and some date will be pre-selected in the calendar based on some biz rules.
Thanks for your fast reply, it's really appreciated.
Okay. As I said, I don't think this is possible. Unless you create your own dropdown editor like I described above. But I'm still not sure it can be done.
Perhaps you can Submit a feature request to Infragistics.