Hello,
I am training as a future software developper, so maybe my problem can be solved differently, but for education the following problem is the problem (and not some code with a specific aim).
Have have an application (a Mastermind clone) in Windows Forms mode.
Everything is inside of different UserControls wich contain a variety of components (as labels, buttons etc.)
I can navigate between the UserControls that all have the same MindMasterForm as parent. And now I finally have another form (MindMasterColourForm), from which I want to set the properties of any component on the active UserControlGame on the MindMasterForm.
I can not access the components of UserControlGame from within MindMasterColourForm.
UserControlGame
public partial class UserControlGame : UserControl
{
public UserControlGame()
{
InitializeComponent();
for (int i = 0; i < GlobalVariables.configsetup[0]; i++)
{
SlotField[i] = new System.Windows.Forms.Panel();
SlotContainer[i] = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
SlotForm[i] = new Microsoft.VisualBasic.PowerPacks.OvalShape();
flowLayoutPanel1.Controls.Add(SlotField[i]);
SlotField[i].Controls.Add(SlotContainer[i]);
SlotField[i].Margin = new System.Windows.Forms.Padding(5);
SlotField[i].Name = "SlotField" + (i + 1).ToString();
SlotField[i].Size = new System.Drawing.Size(50, 50);
SlotField[i].TabIndex = 0;
SlotField[i].TabStop = false;
SlotContainer[i].Location = new System.Drawing.Point(0, 0);
SlotContainer[i].Margin = new System.Windows.Forms.Padding(0);
SlotContainer[i].Name = "SlotContainer" + (i + 1).ToString();
SlotContainer[i].Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] { SlotForm[i] });
SlotContainer[i].Size = new System.Drawing.Size(50, 50);
SlotContainer[i].TabIndex = 0;
SlotContainer[i].TabStop = false;
SlotForm[i].BorderColor = System.Drawing.Color.Black;
SlotForm[i].BorderWidth = 7;
SlotForm[i].Enabled = false;
SlotForm[i].FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
SlotForm[i].FillStyle = Microsoft.VisualBasic.PowerPacks.FillStyle.Solid;
SlotForm[i].Location = new System.Drawing.Point(5, 5);
SlotForm[i].Name = "SlotForm" + (i + 1).ToString();
SlotForm[i].Size = new System.Drawing.Size(33, 33);
}
}
MindMasterColourForm ColourForm = new MindMasterColourForm();
System.Windows.Forms.Panel[] SlotField = new System.Windows.Forms.Panel[GlobalVariables.configsetup[0]];
Microsoft.VisualBasic.PowerPacks.ShapeContainer[] SlotContainer = new Microsoft.VisualBasic.PowerPacks.ShapeContainer[GlobalVariables.configsetup[0]];
Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm = new Microsoft.VisualBasic.PowerPacks.OvalShape[GlobalVariables.configsetup[0]];
private void buttonSetUp_Click(object sender, EventArgs e)
{
Hide();
BasicFunctions.setuppage();
}
private void buttonQuit_Click(object sender, EventArgs e)
{
Hide();
ColourForm.Close();
BasicFunctions.startpage();
}
private void UserControlGame_Load(object sender, EventArgs e)
{
ColourForm.Location = new Point(this.Parent.Location.X + 521, this.Parent.Location.Y + 383);
ColourForm.Show();
GlobalVariables.position = new int[GlobalVariables.configsetup[2] + 1, GlobalVariables.configsetup[0] + 2];
int[] colorvec;
colorvec = new int[GlobalVariables.configsetup[1]];
Random rand = new Random();
}
}
MindMasterColourForm
{
public MindMasterColourForm()
{
InitializeComponent();
}
private void MindMasterColourForm_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
Using button1_Click I want to change the properties of; say, SlotForm.BorderColor?
How can I do that?