Hi.I'm working with an UltraDateTimeEditor and in an special situation I need to avoid the edition.If i use then next code
Private Sub udte1_BeforeEnterEditMode(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles udte1.BeforeEnterEditMode
MessageBox.Show("BeforeEnterEditMode Event")e.Cancel = True
End Sub
any time I click the DropDown Button I get 3 times then "BeforeEnterEditMode Event" message. If I try to edit clicking the textbox I get 2 times the same message.I'm using NetAdvange 12.2 Win CLR4x
Hello,
Probably workaround for you will be to make component read only instead to cancel BeforEnterEditMode event. So the user again will not be allowed to change the value of the component in you will be able to display your message. Please see attached sample.
I hope that this will helps you.
Hi,
I'm sorry, I misread your original question. I thought you were using BeforeExitEditMode.
Showing a MessageBox in BeforeEnterEditMode is a very unusual thing to do, and I don't know if it's feasible to get this to work. Every time you show a MessageBox, the control will lose focus and when the MessageBox closes, the UltraDateTimeEditor will re-enter Edit mode and show the MessageBox again. So, of course this caused an infinite loop.
I don't see any way around that.
I tried with your example but I still have the same problem, it's looks like enter in an infinite loop.
My code:
Private Sub udte1_BeforeEnterEditMode(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles udte1.BeforeEnterEditMode udte1.BeginInvoke(New MethodInvoker(AddressOf ShowMsg)) e.Cancel = True End Sub Private Sub ShowMsg() Try MessageBox.Show("BeforeEnterEditMode Event") Catch ex As Exception End Try End Sub
I just answered a very similar question here: MessageBox in BeforeRowDeactivate affecting ClickCell event - NetAdvantage for Windows Forms - WinGrid
You should try to avoid showing a MessageBox inside events where the focus is already in the process of changing. But you can use the same BeginInvoke technique I used in the other thread to avoid the event problems.