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.