Dynamically generate control arrays in. net

Source: Internet
Author: User
Tags arrays
The majority of developers started from BASIC, and Windows developers started from VB. The changes from vb to vb.net are indeed not small, in the past, a lot of control arrays were used in. net, but the time is okay. This is used in one of my programs. Today, I pasted this class, this is what I saw from MSDN a long time ago.
//*********************************
// Dynamically add and delete array controls
// Students who design the project can reference this class.
// Fan Weixiao
//*********************************
Namespace gradeSystem
{
//**************************
// Class textBoxArray implements dynamic addition and deletion
// TextBox functions
//**************************
Public class textBoxArray: System. Collections. CollectionBase
{
Private readonly System. Windows. Forms. Form HostForm;
// Constructor
Public textBoxArray (System. Windows. Forms. Form Host)
{
HostForm = Host;
}
// Add a textbox control using the addNewTextBox method
Public void addNewTextBox ()
{
If (this. Count <7)
{
// Create a new textbox instance.
System. Windows. Forms. TextBox aTextBox = new System. Windows. Forms. TextBox ();
// Add it to the internal list of the set
This. List. Add (aTextBox );
// Add TextBox to the set list of the forms referenced by the HostForm field
HostForm. Controls. Add (aTextBox );
// Set the initial attribute
ATextBox. Left = (Count-1) * 130 + 70;
ATextBox. Top = 160;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.