Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'check first1 on load Dim selectedIndex1 As Integer = CheckedListBox1.SelectedIndex selectedIndex1 = 1 CheckedListBox1.SetItemChecked(selectedIndex1, True) ';check first2 on load Dim selectedIndex2 As Integer = CheckedListBox2.SelectedIndex selectedIndex2 = 1 CheckedListBox2.SetItemChecked(selectedIndex2, True) End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim itemChecked As String itemChecked = CheckedListBox1.SelectedItem Dim itemChecked2 As String itemChecked2 = CheckedListBox2.SelectedItem If (CheckedListBox1.SelectedItem <> "") Then Dim casuche1 As Object For Each casuche1 In CheckedListBox1.CheckedItems Next Else MessageBox.Show("You must select RAM allocated in first form") Exit Sub End If If (CheckedListBox2.SelectedItem <> "") Then Dim casuche2 As Object For Each casuche2 In CheckedListBox2.CheckedItems Next Else MessageBox.Show("You must select RAM allocated in second form") Exit Sub End If End End Sub Private Sub CheckedListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox2.SelectedIndexChanged If CheckedListBox2.CheckedItems.Count > 1 Then For Each itemChecked2 In CheckedListBox2.CheckedIndices CheckedListBox2.SetItemChecked(itemChecked2, False) Next End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)