问题
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