Quantcast
Viewing all articles
Browse latest Browse all 21975

How to handle the call to functions of an object in an array

Hi,

Based on Sapiens PrimalForms CE, I have started developping GUI for my admin scripts.

Now I would like to get a step further by dynamically generating code based on the data available.

I am working on a list of machine and for each and every of them, I would like to create a TabPage within an existing TabControl.

So I have a form and a tabcontrol defined together with my list of TabPage

$TabVMs = @()

The I have this function to create my TabPage and store it in an array

Function AddNewTab ($TabName)
{ $TmpTab = New-Object System.Windows.Forms.TabPage

 $TmpTab.DataBindings.DefaultDataSourceUpdateMode = 0
 $System_Drawing_Point = New-Object System.Drawing.Point
 $System_Drawing_Point.X = 4
 $System_Drawing_Point.Y = 22
 $TmpTab.Location = $System_Drawing_Point
 $TmpTab.Name = $TabName
 $System_Windows_Forms_Padding = New-Object System.Windows.Forms.Padding
 $System_Windows_Forms_Padding.All = 3
 $System_Windows_Forms_Padding.Bottom = 3
 $System_Windows_Forms_Padding.Left = 3
 $System_Windows_Forms_Padding.Right = 3
 $System_Windows_Forms_Padding.Top = 3
 $TmpTab.Padding = $System_Windows_Forms_Padding
 $System_Drawing_Size = New-Object System.Drawing.Size
 $System_Drawing_Size.Height = 393
 $System_Drawing_Size.Width = 555
 $TmpTab.Size = $System_Drawing_Size
 $TmpTab.TabIndex = 0
 $TmpTab.Text = $NameTab
 $TmpTab.UseVisualStyleBackColor = $True
 $TmpTab.add_Click($handler_TabPage:_Click)

 $TabVMs += $TmpTab

 }

and then I call

AddNewTab "VM1"
$MyControlTab.Controls.Add($TabVMs[$TabVMs.Count-1])

I have tried all the syntaxes I could think of, with no luck.

Is what I am trying to do even possible, managing my tabs in an array and create the exact same tab dynamically for each and every computer ?

Many thanks in advance for your help


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>