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
695
Why choose a date in DateTimePicker trigger UltraGrid's LostFocus event?
posted

I attached LostFocus event to my UltraGrid due to certain purpose.

However, I found that when I choosed a date in a cell's DateTimePicker in the UltraGrid, the ActiveCell.Text is always the original value in the LostFocus event, instead of the new date I had just choosed.

Why choose a date in a DateTimePicker will trigger the UltraGrid's LostFocus event? Isn't it should be trigger only if I move out from the grid?

Without attach to the LostFocus event, then the ActiveCell.Text is correctly returned. 

I couldn't simulate it in sample application.

 

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    It's generally not a good idea to use the GotFocus and LostFocus events in a DotNet Windows Forms application. Microsoft's documentation advises against using these events because they are directly tied to Windows Messages, and my not accurately reflect what's happening in the application.

    crystal_szeyin said:
    Why choose a date in a DateTimePicker will trigger the UltraGrid's LostFocus event? Isn't it should be trigger only if I move out from the grid?

    When you drop down the DateTimeEditor in a cell and click on it, the MonthCalendar control in the dropdown takes focus, so the grid loses focus. The same thing happens if you go into edit mode on any text cell - the TextBox control takes focus away from the grid.

    That's why you should use the Enter and Leave events in DotNet and not GotFocus and LostFocus.

Children
No Data