Imports System Imports System.Drawing Imports System.Windows.Forms
Namespace DefaultNamespace Public Class MainForm Inherits System.Windows.Forms.Form Private checkBox1 As CheckBox Private checkBox2 As CheckBox Private checkBox3 As CheckBox Private checkBox4 As CheckBox Private checkBoxAll(4) As CheckBox Private button1 As Button Private button2 As Button
Public Shared Sub Main Dim fMainForm As New MainForm fMainForm.ShowDialog() End Sub
Public Sub New() MyBase.New InitializeComponent checkBoxAll(0) = checkBox1 checkBoxAll(1) = checkBox2 checkBoxAll(2) = checkBox3 checkBoxAll(3) = checkBox4 End Sub
Private Sub InitializeComponent() checkBox1 = New CheckBox checkBox2 = New CheckBox checkBox3 = New CheckBox checkBox4 = New CheckBox button1 = New Button button2 = New Button SuspendLayout checkBox1.Location = New Point(50, 50) checkBox1.Size = New Size(100, 25) checkBox1.Text = "Valg 1" checkBox2.Location = New Point(50, 100) checkBox2.Size = New Size(100, 25) checkBox2.Text = "Valg 2" checkBox3.Location = New Point(50, 150) checkBox3.Size = New Size(100, 25) checkBox3.Text = "Valg 3" checkBox4.Location = New Point(50, 200) checkBox4.Size = New Size(100, 25) checkBox4.Text = "Valg 4" button1.Location = New Point(200, 100) button1.Size = New Size(50, 25) button1.Text = "Set" AddHandler button1.Click, AddressOf Button1Click button2.Location = New Point(200, 150) button2.Size = New Size(50, 25) button2.Text = "Clear" AddHandler button2.Click, AddressOf Button2Click ClientSize = New Size(300, 250) Controls.Add(checkBox1) Controls.Add(checkBox2) Controls.Add(checkBox3) Controls.Add(checkBox4) Controls.Add(button1) Controls.Add(button2) Name = "Main Form" Text = "Main Form" ResumeLayout(False) End Sub
Private Sub Button1Click(sender As System.Object, e As System.EventArgs) Dim i As Integer For i = 0 To 3 checkBoxAll(i).Checked = True Next End Sub
Private Sub Button2Click(sender As System.Object, e As System.EventArgs) Dim i As Integer For i = 0 To 3 checkBoxAll(i).Checked = False Next End Sub End Class End Namespace
Imports System Imports System.Drawing Imports System.Windows.Forms
Namespace DefaultNamespace Public Class MainForm Inherits System.Windows.Forms.Form Private checkBoxAll(4) As CheckBox Private button1 As Button Private button2 As Button
Public Shared Sub Main Dim fMainForm As New MainForm fMainForm.ShowDialog() End Sub
Public Sub New() MyBase.New InitializeComponent End Sub
Private Sub InitializeComponent() Dim i As Integer For i = 0 To 3 checkBoxAll(i) = New CheckBox Next button1 = New Button button2 = New Button SuspendLayout For i = 0 To 3 checkBoxAll(i).Location = New Point(50, 50 + i * 50) checkBoxAll(i).Size = New Size(100, 25) checkBoxAll(i).Text = "Valg " & (i + 1) Next button1.Location = New Point(200, 100) button1.Size = New Size(50, 25) button1.Text = "Set" AddHandler button1.Click, AddressOf Button1Click button2.Location = New Point(200, 150) button2.Size = New Size(50, 25) button2.Text = "Clear" AddHandler button2.Click, AddressOf Button2Click ClientSize = New Size(300, 250) For i = 0 To 3 Controls.Add(checkBoxAll(i)) Next Controls.Add(button1) Controls.Add(button2) Name = "Main Form" Text = "Main Form" ResumeLayout(False) End Sub
Private Sub Button1Click(sender As System.Object, e As System.EventArgs) Dim i As Integer For i = 0 To 3 checkBoxAll(i).Checked = True Next End Sub
Private Sub Button2Click(sender As System.Object, e As System.EventArgs) Dim i As Integer For i = 0 To 3 checkBoxAll(i).Checked = False Next End Sub End Class End Namespace
Imports System Imports System.Drawing Imports System.Windows.Forms Namespace DefaultNamespace
Public Class MainForm Inherits Form Private a262 As CheckBox Private a263 As CheckBox Private a261 As CheckBox Private a264 As CheckBox Private button1 As Button
Public Sub New() InitializeComponent End Sub
<STAThread()> _ Public Shared Sub Main(ByVal args As String()) Application.Run(New MainForm) End Sub
Private Sub InitializeComponent() button1 = New Button a261 = New CheckBox a263 = New CheckBox a262 = New CheckBox a264 = New CheckBox SuspendLayout button1.Location = New Point(50, 450) button1.Size = New Size(300, 50) button1.Name = "button1" button1.Text = "Set" AddHandler button1.Click, AddressOf Button1Click a261.Location = New Point(50, 50) a261.Name = "a261" a261.Text = "#1" a262.Location = New Point(50, 150) a262.Name = "a262" a262.Text = "#2" a263.Location = New Point(50, 250) a263.Name = "a263" a263.Text = "#3" a264.Location = New Point(50, 350) a264.Name = "a264" a264.Text = "#4" ClientSize = New Size(400, 550) Controls.Add(button1) Controls.Add(a264) Controls.Add(a263) Controls.Add(a262) Controls.Add(a261) Name = "MainForm" Text = "Main Form" ResumeLayout(False) End Sub
Sub Button1Click(ByVal sender As Object, ByVal e As System.EventArgs) For Each c As Control In Controls If TypeOf c Is CheckBox Then If c.Name.IndexOf("a26") = 0 Then CType(c, CheckBox).Checked = True End If End If Next End Sub End Class End Namespace
heh :P så mangler jeg bare at finde ud af hvordan VS laver kaffe... jeg kigger på det senere når jeg har tid - tak for tiden og for svaret samt uddybende kommentare :)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.