wird nur der RadioButton "Holz" angezeigt. Kommentiere ich die erste Zeile aus wird nut der RadioButton "Aluminium" angezeit. Aber niemals beide bzw alle 5 (Array RadioName)!
Könnt Ihr mir da weiterhelfen?
Option Strict On Public Class Form1
Dim Ctrl As ControlService = New ControlService
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim CmdArr(0 To 2) As Control Dim TxtArr(0 To 3) As Control Dim RdoArr(0 To 4) As Control Dim GrpBoxArr(0 To 1) As Control
Dim RadioNames(0 To 4) As String RadioNames(0) = "Holz" RadioNames(1) = "Aluminium" RadioNames(2) = "Glas" RadioNames(3) = "Eisen" RadioNames(4) = "Blei"
For Each i As Control In CmdArr Me.Controls.Add(i) Next
For Each i As Control In TxtArr Me.Controls.Add(i) Next
For Each i As Control In GrpBoxArr Me.Controls.Add(i) Next End Sub End Class
Imports System.ComponentModel Imports System.Windows.Forms.Control Public Class ControlService
#Region "BUTTON" Public Function SetButton(pName As String, pText As String, pLeft As Integer, pTop As Integer, pHeight As Integer, pWidth As Integer) As Control
Dim CmdButton = New Button With CmdButton .Name = pName .Text = pText .Left = pLeft .Top = pTop .Height = pHeight .Width = pWidth End With 'AddHandler CmdButton.Click, AddressOf CmdButton_Click Return CmdButton End Function #End Region
#Region "TEXTBOX" Public Function SetTextBox(pName As String, pText As String, pLeft As Integer, pTop As Integer, pHeight As Integer, pWidth As Integer, pEnabled As Boolean) As Control
Dim TxtBox = New TextBox With TxtBox .Name = pName .Text = pText .Left = pLeft .Top = pTop .Height = pHeight .Width = pWidth .Enabled = pEnabled End With Return TxtBox End Function #End Region
#Region "GROUPBOX" Public Function SetGroupBox(pName As String, pText As String, pLeft As Integer, pTop As Integer, pHeight As Integer, pWidth As Integer, pBorderSyle As Integer, pControl As Control) As Control
Dim GrpBox = New GroupBox With GrpBox .Parent = Form1 .Name = pName .Text = pText .Left = pLeft .Top = pTop .Height = pHeight .Width = pWidth .Controls.Add(pControl) End With Return GrpBox End Function
#End Region
#Region "LABEL" Public Function SetLabel(pName As String, pText As String, pLeft As Integer, pTop As Integer, pHeight As Integer, pWidth As Integer) As Control
Dim LblField = New Label With LblField .Name = pName .Text = pText .Left = pLeft .Top = pTop .Height = pHeight .Width = pWidth End With Return LblField End Function
#End Region
#Region "RADIOBUTTON" Public Function SetRadioButton(pName As String, pText As String, pLeft As Integer, pTop As Integer, pHeight As Integer, pWidth As Integer, pParent As Control) As Control
Dim RdoButton = New RadioButton With RdoButton .Parent = pParent .Name = pName .Text = pText .Left = pLeft .Top = pTop .Height = pHeight .Width = pWidth End With Return RdoButton End Function #End Region
#Region "EVENTS" Sub CmdButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'Form1.TxtBox.Text = "Test" End Sub