Hello All,
I am having one wrapper class on UltraDateTimeEditor say CustomUltraDateTimeEditor
e.g. -
public partial class CustomUltraDateTimeEditor : UltraDateTimeEditor { #region Datamebers
private DateTime? oldDateValue; private string messageTitle = string.Empty; private string timeZone;
#endregion
#region Constructor
///
/// Initializes a new instance of the class. /// public CustomUltraDateTimeEditor () { this.InitializeComponent(); this.BeforeEnterEditMode += this.CustomUltraDateTimeEditorBeforeEnterEditMode; this.BeforeExitEditMode += this.CustomUltraDateTimeEditorBeforeExitEditMode; this.AfterDropDown += this.CustomUltraDateTimeEditorAfterDropDown; this.Enter += this.CustomUltraDateTimeEditorEnter; }
....
This control I have embedded into one of Ultragrid's column.
e.g.
col.EditorComponent = new CustomUltraDateTimeEditor{};
Now Whenever I click on cell containing CustomUltraDateTimeEditor control, I need to call AfterDropDown event of that. but in current situation its not happening.
As I need a CustomUltraDateTimeEditor controls IsHandleCreated property as true, for overriding current system time of control. (For supporting multitimezone)
Any response will be highly appercitaed. :) Thanks in advance..!
Hi Ganesh,
When you set a control as the editor of a column, we don’t use the control directly. We use just the internal editor of the control, as such the events on the control will not be fired. To get the event behavior that you want you will need to hook up the events on the column’s Editor, as in below:
col.Editor.AfterDropDown += Editor_AfterDropDown;
Please let me know if you have any additional questions.
Sincerely,Sahaja KokkalagaddaAssociate Software DeveloperInfragistics, Inc.
Hi Sahaja,
First of all lots of thanks to your reply..
But my problem is something different actually.
My basic need is to provide multi-timezone feature to UltraDateTimeEditor.
and for that I have a code which is used to set DefaultDateTime of control based on timezone set to that control.
I have following method in CutomUltraDateTimeEditor class which is extended from control UltraDateTimeEditor.Which sets DateTime according according to timezone(which is stored "Today" property of control)
private void UpdateCalendarTodayDate() { if (!this.IsHandleCreated) { return; }
// Get the date to set as "Today". var st = DateTimeToSysTime(this.Today);
var editorFieldInfo = typeof(DateTimeEditor).GetField("monthDropDown", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField); if (editorFieldInfo == null) { return; }
var editorDropDown = editorFieldInfo.GetValue(this.Editor) as MonthDropDown; /*IF I call this explicitly when control is ebedded in UltraGrid I am getting null value in editorDropDown */
if (editorDropDown == null) { return; }
var dropDownHandle = editorDropDown.Handle;
// Set the "Today" value of the calendar control. UnsafeNativeMethods.SendMessage(new HandleRef(this, dropDownHandle), NativeMethods.MCM_SETTODAY, 0, st);
}
Now When I use this CustomUltraDateTime control directly on form I am able to set its date according to timezone.
But now when I am using same control in one of column of UltraGrid as I explained earlier I am unable to do the same, as this controls events are not getting fired as well as if I do this explicitly I am not getting its Handle i.e. IsHandleCreated=false always.
Now Is there any way to achieve this functionality when I use UltraDateTime editor in UltraGrid column as I am facing issue in that case.
Why I asked earlier about AfterDropDown event of CustomUltraDateTime class as I am calling above UpdateCalendarTodayDate method from that AfterDropDown event and
as same event is getting called when I use this CustomUltraDateTime control directly on form and click on control at run time. but this is not happening when I am using same in Ultragrid's one of column as AfterDropDown event of CustomDropDown is not getting called when I click on that control cell.
I'm not sure what you mean by "multiple date entry format". But the control does not support entering letters or abbreivations for the month. It only accepts numeric values.
Hi Mike,
While using UltraDateTimeEditor in Infragistics grid control (EditorComponent), while using different date format like ‘dMMMyyyy’ or ''d/MMM/yyyy' for MaskInput property I am getting system error. I think it doesn't support multiple date entry format.
EditingControl = new UltraDateTimeEditor { Nullable = true, MaskInput = CreateInputMask(Model.DateFormat), //'d/MMM/yyyy' }
Is there any way to fix this issue, Please suggest.
Thanks in advance..!
Ganesh
Hi,
The grid doesn't use the Control you specify for EditorComponent. The control merely provides a copy of it's internal editor for use by the grid. So none of the events on the DateTimeEditor control will fire.
You have a few potential options here.
1) You could write your own editor derived from DateTimeEditor. This is not the same as deriving an editor control. And it will be very complex and involve a lot of duplication of the effort you already did for your derived control.
2) You could handle events of the grid and do the same thing you are doing in the event of your derived DateTimeEditor control. The grid has events like AfterCellListDropdown which you could use.
3) You could actually embed your derived control into the grid using the UltraControlContainerEditor. This seems like your best option, since it doesn't involve duplicating any of the work you already did. But it might involve making some small changes to your derived control and there's a bit of a learning curve if you have no used the UltraControlContainerEditor before.