JavascriptProva

giovedì 8 agosto 2013

Griglie orizzontali e verticali.

Con una piccola modifica, distinguo la mia Griglia originale in due tipi: una griglia orizzontale, in cui le caselle vengono disposte progressivamente in file, e una griglia verticale, in cui vengono disposte in colonne.
Imports System.Windows.Forms
Public Class HorGriglia(Of T As {New, Control})
    Sub New(ByRef myForm As Form, ByVal numCaselle As Integer, ByVal rowLength As Integer)
        For n As Integer = 0 To (numCaselle - 1)
            Dim casella As T = New T

            casella.Left = casella.Width * (n Mod rowLength)
            casella.Top = casella.Height * (n \ rowLength)

            myForm.Controls.Add(casella)
        Next
    End Sub

End Class
Public Class VertGriglia(Of T As {New, Control})
    Sub New(ByRef myForm As Form, ByVal numCaselle As Integer, ByVal colLength As Integer)
        For n As Integer = 0 To (numCaselle - 1)
            Dim casella As T = New T

            casella.Top = casella.Height * (n Mod colLength)
            casella.Left = casella.Width * (n \ colLength)

            myForm.Controls.Add(casella)
        Next
    End Sub

End Class
Tutto si rivela esatto, e con un codice del genere:
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim miaGriglia As New VertGriglia(Of TextBox)(Me, 30, 4)
    End Sub
End Class
...ottengo trenta TextBoxes disposte in colonne di 4 elementi:



Tutto incasellato nella mia DLL.

Nessun commento:

Posta un commento