programmatically add/remove windows components

  • Thread starter Thread starter Tzvika
  • Start date Start date
T

Tzvika

Hi,
Is there a way to programmatically add/remove windows components in c# or in
any other language
What is the API fro that?
 
Um... what is a "windows component"? Whatever it is, there is certainly a
way to do it programatically in some language.

If you mean can you add controls such as buttons or textboxes in C#, then
yes it is very easy. The ability to do this is pretty much built into the C#
language/.NET framework. You don't need a special API, you just need to
learn how to use C#.
 
To echo Rachel's post, all you have to do is instantiate new
Windows.Forms.Control objects (such as Label, ComboBox, TextBox, etc)
and then add them to the controls on your form. Similarly, you can
remove controls from a form by calling the Remove method on your form's
Controls property.

The easiest way to get a quick lesson on how to add new controls
programmatically is to create a new form using Visual Studio, place
controls on it, and then go and look in your source code in the section
marked "Windows Forms Designer generated code". Remember that the
Designer does not perform any hidden magic: it just generates code to
create what you created visually, so you can do the same things it does
in your code with the same effect.
 
Back
Top