I am trying to change the properties of an existing button.
Here's the logic behind it:
- interrogate database and create button names list
- create all buttons inside control
Later:
- interrogate database and create button names list (just to double check if there are any updates)
- create a new button and assign name
- check if the button exists already
- if YES, reposition this button to new location
Basically, all this comes to is: if btn exists, select it somehow and change its properties.
Here's the code wrap around it, with the commented portion definitely not working
Here's the logic behind it:
- interrogate database and create button names list
- create all buttons inside control
Later:
- interrogate database and create button names list (just to double check if there are any updates)
- create a new button and assign name
- check if the button exists already
- if YES, reposition this button to new location
Basically, all this comes to is: if btn exists, select it somehow and change its properties.
Here's the code wrap around it, with the commented portion definitely not working
C#:
controlName = "btnModelSelection" + i.ToString(); Button btn = new Button();
btn.Name = controlName;
if (this.pnlModelSelection.Controls.Contains(btn))
{
//this.pnlModelSelection. = new System.Drawing.Point(btnX, btnY);
}
else
{
btn.Size = new System.Drawing.Size(btnWidth, btnHeight);
btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
btn.Location = new System.Drawing.Point(btnX, btnY);
btn.Text = modelSelectionButtonNames[i];
btn.Font = new Font("Microsoft Sans Serif", 12);
this.pnlModelSelection.Controls.Add(btn);
}