我在TileContainer上有一个CheckButton。 我在CheckButton的Checked Event上展示了一个PopUp菜单。 现在,我需要在事件结束时取消选中CheckButton。
this.tileContainer1.Buttons.AddRange(new DevExpress.XtraEditors.ButtonPanel.IBaseButton[] {
new DevExpress.XtraBars.Docking2010.WindowsUIButton("ShowList", global::DMS.Properties.Resources.speech_bubble, -1, DevExpress.XtraBars.Docking2010.ButtonStyle.CheckButton, 0)});
答案 0 :(得分:1)
如果我理解您的方案正确,您可以使用以下approch:
WindowsUIButton checkButton = new WindowsUIButton()
{
Caption = "Check Button",
Style = ButtonStyle.CheckButton
};
checkButton.CheckedChanged += checkButton_CheckedChanged;
tileContainer1.Buttons.Add(checkButton);
//...
int reentranceCount = 0;
void checkButton_CheckedChanged(object sender, EventArgs e) {
if(reentranceCount > 0) return;
/*do some stuff */
Uncheck((WindowsUIButton)sender);
}
void Uncheck(WindowsUIButton button) {
reentranceCount++;
try {
button.Checked = false;
}
finally { reentranceCount--; }
}
<强>更新强>
如果您使用的是TileContiner.ButtonChecked事件,则应按以下步骤更新上述代码:
//...
tileContainer1.ButtonChecked += tileContainer_ButtonChecked;
//...
void tileContainer_ButtonChecked(object sender, ButtonEventArgs e) {
if(reentranceCount > 0) return;
/*do some stuff */
Uncheck((WindowsUIButton)e.Button);
}