What is the proper way to replace one winform element with another element when something is triggered? For example, I would like to replace a button with a text box in the same position and the same dimensions.
If you do not (for some reason) want to simply change their visibility, you can add and remove them from the form's Controls collection.
// contrived example...
private void Swap( Control toAdd, Control toRemove )
{
this.Controls.Remove( toRemove );
this.Controls.Add( toAdd );
}
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