In my UltraDayView control I am trying to respond to the user typing in the "Click to Add Appointment" area. I want to do a custom function on each keypress when the user types something in there. I have been trying to figure out how to catch the KeyPress event in this control but I'm having difficulty.
I tried using a CreationFilter, but there doesn't seem to be any exposure of the OnKeyPress event, like there is for OnClick. Can someone post some sample code, that shows how to handle the KeyPress event in the Click to Add Appointment area? That would be very helpful.
I also considered using the KeyMappings approach, but I want to handle every key that they type into this area (not just 1 or 2 specific keys), so it isn't clear that I can do it that way.
FYI I am using C#. I have tried this with Infragistics version 7.1 and version 8.3, both without success.
Thanks in advance for your help.
Thank you for this simple and effective solution. It works great.
FYI, for the final solution, I used the KeyUp event instead, which works better to get the control's actual text. I get the Control's text with the following code in the KeyUp handler:
{
string CurrentName = textBox.Text;
MyFunction(CurrentName);
}
You could hook the KeyPress event for the edit control that is used for the editing (see below), but there is no way to distinguish the ClickToAdd appointment from any other appointment. If you like you can submit a feature request for a property that returns that information.
this.dayView.ControlAdded += new ControlEventHandler(this.dayView_ControlAdded);this.dayView.ControlRemoved += new ControlEventHandler(this.dayView_ControlRemoved);
private void dayView_ControlAdded(object sender, ControlEventArgs e){ if ( e.Control is Infragistics.Win.EmbeddableTextBox ) e.Control.KeyPress += new KeyPressEventHandler(this.OnDayViewAppointmentEditorKeyPress); }
void dayView_ControlRemoved(object sender, ControlEventArgs e){ if ( e.Control is Infragistics.Win.EmbeddableTextBox ) e.Control.KeyPress -= new KeyPressEventHandler(this.OnDayViewAppointmentEditorKeyPress); }
private void OnDayViewAppointmentEditorKeyPress(object sender, KeyPressEventArgs e){}