문제

I have a CheckButton on TileContainer. I showed a PopUp Menu on Checked Event of CheckButton. Now, I need to Uncheck that CheckButton at the end of the event.

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)});
도움이 되었습니까?

해결책

If I understand your scenario correctly, you can use the following 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--; }
}

Update:
If you are using the TileContiner.ButtonChecked event you should update the code above as follows:

//...
tileContainer1.ButtonChecked += tileContainer_ButtonChecked;
//...
void tileContainer_ButtonChecked(object sender, ButtonEventArgs e) {
    if(reentranceCount > 0) return;
    /*do some stuff */
    Uncheck((WindowsUIButton)e.Button);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top