Control Arrays Support

    Control Arrays do not exist in a natural way in .NET. In order to achieve an equivalent behavior, the VBUC generates each of the control array elements as an individual control with its own declaration. It also applies all the necessary initializations and event bindings to each control element. Additionally, the VBUC declares an array containing all of the control array elements, allowing to reference the elements by index with a variable to execute iterations over the array.

    All the references to the control array are changed to either a direct reference to the corresponding field variable or an indirect reference to the array element.

    Declaration of control array elements:


    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration

    public  System.Windows.Forms.Button _Command1_0;
    public  System.Windows.Forms.Button _Command1_1;
    public  System.Windows.Forms.Button _Command1_2;
    

    Declaration of array:

    public System.Windows.Forms.Button [] Command1 = new System.Windows.Forms.Button [3];
    

    For each control array, an initialization method is added to the containing class:

    void  InitializeCommand1()
    {
        this.Command1[0] = _Command1_0;
        this.Command1[2] = _Command1_2;
        this.Command1[1] = _Command1_1;
    }
    

    Initializations and event bindings

    All the needed attributes are initialized with the InitializeComponent()method The most commonly used attributes are configured as follows:

    this._Command1_0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    this._Command1_0.Text = "1";
    this._Command1_0.Font = new System.Drawing.Font("Tahoma", 9.75f, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
    this._Command1_0.Size = new System.Drawing.Size(33, 33);
    this._Command1_0.Location = new System.Drawing.Point(48, 184);
    this._Command1_0.TabIndex = 2;
    this._Command1_0.BackColor = System.Drawing.SystemColors.Control;
    this._Command1_0.CausesValidation = true;
    this._Command1_0.Enabled = true;
    this._Command1_0.ForeColor = System.Drawing.SystemColors.ControlText;
    this._Command1_0.Cursor = System.Windows.Forms.Cursors.Default;
    this._Command1_0.RightToLeft = System.Windows.Forms.RightToLeft.No;
    this._Command1_0.TabStop = true;
    this._Command1_0.Name = "_Command1_0"; 
    

    The event handling method is attached to the the event listener with the following code:

    this._command1_0.Click += new System.EventHandler (this.command1_0_Click);

    Where command1_0_click is implemented and it contains the code to be executed by the event.