Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
680
UltraDateTimeEditor Ig14.1
posted

I am trying to capture the click event of the spin button and it is not firing in the event I would expect. The reason I am trying this derives from the fact that when the value of the editor is set to null and the user clicks the up or down spin button the date and time starts as DateTime.Now.  My implementation needs to display only the military time portion in the editor and this works fine except that the value must be in 1/2 hour increments rounded to the nearest 1/2 hour like 13:30 or 13:00 and cannot be values like 13:17 or 13:42.  I figured I could capture the spin button click event with the following snippet and handle the value that way but alas it does not work.  Can you "spin" me in the right direction please.  I have attached a sample project that illustrates the point.

dtStart.EditorSpinButtonClick += dtStart_EditorSpinButtonClick;

void dtStart_EditorSpinButtonClick(object sender, Infragistics.Win.UltraWinEditors.SpinButtonClickEventArgs e)
{
MessageBox.Show("Spin");
}

TestSpinButton.zip
  • 48586
    Verified Answer
    posted

    Hello,

     

    I am just checking about the progress of this issue. Let me know If you need my further assistance on this  matter?

     

    Thank you for using Infragistics Components.

  • 48586
    posted

    Hello,

     

    Thank you for the provided sample. The event which you have handled occurs when you have SpinButton in ButtonLeft/ButtonRight collection of the editor and this button was clicked. So if you should managed the value I suggest you to hide default SpinButton:

     

    ultraDateTimeEditor1.SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Never;
    SpinEditorButton spinButton = new SpinEditorButton();
    ultraDateTimeEditor1.ButtonsRight.Add(spinButton);

     

    then in EditorSpinButtonClick you could use code like the following:

     

    TimeSpan offsetInterval = TimeSpan.FromMinutes(30);

                int minutesIntervalDifference = ultraDateTimeEditor1.DateTime.Minute % 30 ;

                switch(e.ButtonType)

                {

                    case SpinButtonItem.NextItem:

                        offsetInterval = minutesIntervalDifference != 0 ? offsetInterval - TimeSpan.FromMinutes(minutesIntervalDifference) : offsetInterval;

                        break;

                    case SpinButtonItem.PreviousItem:

                        offsetInterval = minutesIntervalDifference != 0 ? -TimeSpan.FromMinutes(minutesIntervalDifference)   : -offsetInterval;

                        break;

                }

     

                ultraDateTimeEditor1.DateTime = ultraDateTimeEditor1.DateTime.AddTicks(offsetInterval.Ticks);

     

    Please let me know if you have any further questions.