Question Navigation panel on main form button formatting

LabProARW

Well-known member
Joined
Nov 4, 2019
Messages
52
Programming Experience
1-3
On FrmMain I have a panel LeftPanelMainMenu and a set of buttons to launch various forms. Buttons are for example BtnSampleLogin, BtnRecentSamples ... etc. I have set one BackgroundImage for not used and another lighter one for MouseHover and MouseLeave. The lighter background image is also invoked on MouseClick, which launches the form associated to the button.

What I am trying to do is to have the lighter backgrouindimage stay put on the button when the associated form launches.... and even if I MouseLeave have the navigation button stay lighter background, UNTIL the form that was launched closes. I was expecting to somehow send an event from the form as it closed to notify/change the background image of the original calling button back on FrmMain to reset back to the normal image. I am unable to address the FrmMain buttons from my other closing form. How is this supposed to be done? Since I can't readily find anything on search I must be trying to do something non-standard.

Thanks for helpful comments.
 
Solution
Anyway as an aside, it sounds like what you really want are checkbox style buttons rather than regular buttons. Checkbox style buttons remember their state on click, which is different from regular buttons which "bounce back" to their previous state after being clicked. I don't recall how to do checkbox style buttons in WinForms anymore, but as I recall, it is do-able.
You use an actual CheckBox control and set its Appearance property to Button. You can do the same with RadioButton controls too. Obviously you then need to use the CheckedChanged event to determine when to act.
When you launched the child form, you have reference to the form. You can add an event handler to that form's Closed event. In pseudo-code:
C#:
void btnShowChildForm_Click(...)
{
    // swap button bitmaps here to make button light colored

    var child = new ChildForm();
    child.Closed += new EventHandler(ChildForm_Closed);
    child.Show();
    :
}

void ChildForm_Closed(...)
{
    // swap button bitmaps here to make button dark colored
}

Anyway as an aside, it sounds like what you really want are checkbox style buttons rather than regular buttons. Checkbox style buttons remember their state on click, which is different from regular buttons which "bounce back" to their previous state after being clicked. I don't recall how to do checkbox style buttons in WinForms anymore, but as I recall, it is do-able.
 
Anyway as an aside, it sounds like what you really want are checkbox style buttons rather than regular buttons. Checkbox style buttons remember their state on click, which is different from regular buttons which "bounce back" to their previous state after being clicked. I don't recall how to do checkbox style buttons in WinForms anymore, but as I recall, it is do-able.
You use an actual CheckBox control and set its Appearance property to Button. You can do the same with RadioButton controls too. Obviously you then need to use the CheckedChanged event to determine when to act.
 
Solution
You use an actual CheckBox control and set its Appearance property to Button. You can do the same with RadioButton controls too. Obviously you then need to use the CheckedChanged event to determine when to act.
I do believe you are correct. I will proceed with the check boxes immediately.
Thank you!
 
Back
Top Bottom