| 

.NET C# Java Javascript Exception

1
Hallo Leute,

wenn ich versuche beide Zeilen :
GrpBoxArr(0) = Ctrl.SetGroupBox("GrpMaterial", "Material", 20, 100, 280, 150, 1, RdoArr(0))
GrpBoxArr(0) = Ctrl.SetGroupBox("GrpMaterial", "Material", 20, 100, 280, 150, 1, RdoArr(1))


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"


CmdArr(0) = Ctrl.SetButton("CmdFunction", "Function", 350, 100, 30, 100)
CmdArr(1) = Ctrl.SetButton("CmdSub", "Sub", 350, 180, 30, 100)
CmdArr(2) = Ctrl.SetButton("CmdSubByRef", "Sub (ByRef)", 325, 260, 30, 150)

TxtArr(0) = Ctrl.SetTextBox("TxtDurchmesser", " ", 20, 55, 80, 180, True)
TxtArr(1) = Ctrl.SetTextBox("TxtErgebnisFunction", " ", 600, 100, 80, 200, False)
TxtArr(2) = Ctrl.SetTextBox("TxtErgebnisSub", " ", 600, 180, 80, 200, False)
TxtArr(3) = Ctrl.SetTextBox("TxtErgebnisSubByRef", " ", 600, 260, 80, 200, False)


'CtrlArr(7) = Ctrl.SetRadioButton("Rdo", "Eisen", 120, 120, 40, 150, CtrlArr(14)) 'RadioNames(3)
'Dim k As Integer = 0
'For i As Integer = 0 To 4
RdoArr(0) = Ctrl.SetRadioButton("Rdo" & String.Concat(RadioNames(0)), RadioNames(0), 40, 40, 40, 80, GrpBoxArr(0))
RdoArr(1) = Ctrl.SetRadioButton("Rdo" & String.Concat(RadioNames(1)), RadioNames(1), 40, 60, 40, 80, GrpBoxArr(0))
'CtrlArr(14) = Ctrl.SetGroupBox("GrpMaterial", "Material", 20, 100, 280, 150, 1, CtrlArr(7 + i))
'k = k + 10
'Next


GrpBoxArr(0) = Ctrl.SetGroupBox("GrpMaterial", "Material", 20, 100, 280, 150, 1, RdoArr(0))
GrpBoxArr(0) = Ctrl.SetGroupBox("GrpMaterial", "Material", 20, 100, 280, 150, 1, RdoArr(1))
'CtrlArr(8) = Ctrl.SetLabel("LblDurchmesser", "Durchmesser in (cm)", 15, 25, 50, 250)


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

#End Region

End Class



Vielen Dank für Eure Mühe und Hilfe!!!!


Best Regards,
DonTango
18.10.2019
1 Antwort
0
Ich habs, ich muss das Rdo-Array als ganzes an die GroupBox Funktion übergeben, nicht die Elemente einzeln!
18.10.2019

Stelle deine --Frage jetzt!