Note that there are some explanatory texts on larger screens.

plurals
  1. POWays to Dynamically Create Controls in C#
    primarykey
    data
    text
    <p>What ways can you dynamically create controls in C#? </p> <p>This was objects at first but it would have been more precise to say controls. My terminology was messed up. Thanks Joel.</p> <p>Edit{ Controls that are created during runtime. And are able to be accessed and edited by the program. Does this help? }</p> <p>I like the idea of Dynamic creation and was wondering what ways there were to do this. </p> <p>Please only one per answer, I would like to see how people rank them.</p> <p>eg</p> <pre><code>private Label _lblCLastName = new Label(); private static List&lt;ChildrenPanel&gt; _ListCP = new List&lt;ChildrenPanel&gt;(); public void CreatePanel(Panel Container) { // Created Controls #region Controls _pnlStudent.Controls.Add(_lblCLastName); // // lblCLastName // _lblCLastName.AutoSize = true; _lblCLastName.Location = new System.Drawing.Point(6, 32); _lblCLastName.Name = "lblCLastName"; _lblCLastName.Size = new System.Drawing.Size(58, 13); _lblCLastName.TabIndex = 10; _lblCLastName.Text = "Last Name"; // Adds controls to selected forms panel Container.Controls.Add(_pnlStudent); // Creates a list of created panels inside the class // So I can access user input ListCP.Add(this); } </code></pre> <p>This is a code snippet from something that is close to what I'm talking about. I made another post but didn't quite post the question right. I will be deleting it but atm it is still viewable.</p> <p>If there are still problems please be constructive I don't mind negitive input as long as it's helpful.</p> <p>Edit: I was able to get some answers I was looking for. Thank you to everyone who replied. I will close this when I am able too. If someone else can close it that would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload