Access to the Ok/Accept Or Cancel Button of a RepositoryItemTimeSpanEdit?

三世轮回 提交于 2019-12-24 17:24:07

问题


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.


回答1:


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");
}


来源:https://stackoverflow.com/questions/32382133/access-to-the-ok-accept-or-cancel-button-of-a-repositoryitemtimespanedit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!