1

I need to know if there is a way to access to the events of the buttons inside a RepositoryItemTimeSpanEdit. Image to see the buttons I need the events for: Click Image

I have tried to access in the PopUp event and QueryPopUp, however I can't get the button in any way yet.

Ruchi
  • 1,238
  • 11
  • 32
Thorin
  • 27
  • 7

1 Answers1

0

You can get this form through Form.OwnedForms property in Popup event. The type of this form is DevExpress.XtraEditors.Popup.TimeSpanEditDropDownForm, so you need just to find the form of this type. After that you can access buttons by using TimeSpanEditDropDownForm.OkButton property and TimeSpanEditDropDownForm.CloseButton property.
Here is example:

private void repositoryItemTimeSpanEdit1_Popup(object sender, EventArgs e)
{
    var popupForm = (TimeSpanEditDropDownForm)OwnedForms.FirstOrDefault(item => item is TimeSpanEditDropDownForm);

    if (popupForm == null)
        return;

    popupForm.OkButton.Click += OkButton_Click;
    popupForm.CloseButton.Click += CloseButton_Click;
}

private void OkButton_Click(object sender, EventArgs e)
{
    MessageBox.Show("Ok");
}

private void CloseButton_Click(object sender, EventArgs e)
{
    MessageBox.Show("Cancel");
}
nempoBu4
  • 6,521
  • 8
  • 35
  • 40
  • Thank, this works, but how can I interact with the current value of the `TimeSpanEdit`? I mean, how can I get the value in this event `OkButton_Click` – Thorin Sep 04 '15 at 19:40
  • @Thorin Unfortunately, I have no developer tools right now, so now I can suggest you to iterate through `popupForm.Controls` collection to find out the control with `TimeSpanEdit` type. [Here](http://stackoverflow.com/a/3426721/1805640) is the example of how to find the control of specific type. In `OkButton_Click` event you can get the `popupForm` by the same way through `Form.OwnedForms` property. – nempoBu4 Sep 07 '15 at 07:43