I have a C# WinForms project that's very wizard like in its functionality. The individual steps live on a class called StepPanel, which inherits from the Panel control, within the form and those panels are organized in an array.
What I've run into is that when UpdateUI() is called and walks the array, adjusts the wizards step title text for the current step, it makes sure that all of the inactive steps are hidden, and ensures that the active step is visible, in the right spot, and is the right size.
Here's the code:
private void UpdateUI()
{
// If the StepIndex equals the array length, that's our cue
// to exit.
if (StepIndex == Steps.Length)
{
Application.Exit();
return;
}
for (var xx = 0; xx < Steps.Length; xx++)
{
if (xx == StepIndex)
{
if (!String.IsNullOrEmpty(Steps[xx].Title))
{
LabelStepTitle.ForeColor = SystemColors.ControlText;
LabelStepTitle.Text = Steps[xx].Title;
}
else
{
LabelStepTitle.ForeColor = Color.Red;
LabelStepTitle.Text =
Resources.UiWarning_StepTitleNotSet;
}
}
else
{
Steps[xx].Visible = false;
}
}
Steps[StepIndex].Top = 50;
Steps[StepIndex].Left = 168;
Steps[StepIndex].Width = 414;
Steps[StepIndex].Height = 281;
Steps[StepIndex].Visible = true;
SetNavigationButtonState(true);
}
When everything is said and done, Steps[StepIndex].Visible == false.
I'm still perplexed by this behavior because I was working less than 30 minutes ago.
Although code in your control may still run while invisible, you will not be able to interact with the control through the user interface. If you want to create an invisible control that still responds to user input (for example, mouse clicks), you should create a transparent control.
Control. Visible Property (System.
In C#, you will have to create all but the MainForm. // in a buttonClick on Form1 Form2 f2 = new Form2(); f2. Show(); This will create a new instance each time you click the button.
If you set a parent/container control to Visible = false
then setting any child controls to Visible = true
will have no effect what so ever. The Visible
property of the child control will still be false
.
I don't know if it's what happens in this case since I don't know the structure of the controls but it seems to be a likely scenario.
To solve this you need to first set the parent/contianer control to Visible = true
and THEN the child control(s).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With