aquí adjunto el form completo por si sirve de algo:
Código
Imports System.Windows.Forms Imports System.IO Imports System.Text.RegularExpressions Public Class Form1 Dim filesystem As Object, ThisDir As Object Dim mcheck(0) As CheckBox Dim winampargs As String
Código
#Region "Propertys" Public Property userSelectedPlayerFilePath() As String Get Return playertextbox.Text End Get Set(value As String) playertextbox.Text = value End Set End Property Public Property userSelectedFolderPath() As String Get Return foldertextbox.Text End Get Set(value As String) foldertextbox.Text = value End Set End Property #End Region
Código
#Region "Load / Close" Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load playertextbox.Text = My.Settings.playerpath foldertextbox.Text = My.Settings.folderpath updatecheckboxes() End Sub Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim mCheckados(0) As Int32 Dim Cuantos As Int32 = 0 For i As Int32 = 0 To mcheck.Length - 1 If mcheck(i).Checked = True Then Cuantos += 1 Array.Resize(mCheckados, Cuantos) mCheckados(Cuantos - 1) = i + 1 End If Next My.Settings.Valores = mCheckados My.Settings.Save() End Sub #End Region
Código
#Region "Save & Get settings" Public Sub GenerarPropiedades() Dim CheckedN As String = Nothing For i As Int32 = 0 To mcheck.Length - 1 If mcheck(i).Checked = True Then CheckedN &= i + 1 End If Next My.Settings.Save() End Sub Private Sub CargarPropiedades() 'Obtenemos la Lista de Enteros de los índices Checkados Dim ListaCheckados As Int32() = My.Settings.Valores For i As Int32 = 0 To mcheck.Length - 1 For Each indiceCheckado As Int32 In ListaCheckados mcheck(indiceCheckado - 1).Checked = True Next Next End Sub #End Region
Código
#Region "Draw checkboxes..." Public Sub updatecheckboxes() ' delete the old checkboxes Panel1.Controls.Clear() ' create the new checkboxes Dim filesystem = CreateObject("Scripting.FileSystemObject") Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath) Dim i As Int32 = 0 Array.Resize(mcheck, i + 1) mcheck(i) = New CheckBox With mcheck(i) .AutoSize = True .Location = New Point(10, i * 20) .Name = "CheckBox" & i + 1 End With Me.Panel1.Controls.Add(mcheck(i)) AddHandler mcheck(i).CheckedChanged, AddressOf LlamadaCheckBox i += 1 Next CargarPropiedades() End Sub ' función que se ejecuta cuando cualquier checkbox es clickado Public Sub LlamadaCheckBox(ByVal sender As Object, ByVal e As System.EventArgs) Dim filesystem = CreateObject("Scripting.FileSystemObject") Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath) Dim CheckboxN As CheckBox = CType(sender, CheckBox) If CheckboxN.Checked = True Then winampargs = winampargs & " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote Else winampargs = Replace(winampargs, ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote, "") End If End Sub #End Region
Código
#Region "buttons" ' Folder button Public Sub C1Button3_Click(sender As Object, e As EventArgs) Handles folderbutton.Click Dim folderselected As New System.Windows.Forms.FolderBrowserDialog Dim Resultado As DialogResult folderselected.RootFolder = Environment.SpecialFolder.Desktop Resultado = folderselected.ShowDialog If Resultado.ToString() = "OK" Then userSelectedFolderPath = folderselected.SelectedPath My.Settings.folderpath = folderselected.SelectedPath My.Settings.Save() Dim mcheck(0) As CheckBox updatecheckboxes() End If End Sub ' Player button Public Sub C1Button1_Click(sender As Object, e As EventArgs) Handles playerbutton.Click Dim playerselected As New OpenFileDialog() playerselected.InitialDirectory = Environ("programfiles") playerselected.Title = "Select your favorite music player" playerselected.Filter = "Music players|mpc.exe;mpc-hc.exe;mpc-hc64.exe;umplayer.exe;vlc.exe;winamp.exe;wmp.exe" PlayerDialog.FilterIndex = 1 Dim selection As System.Windows.Forms.DialogResult = playerselected.ShowDialog() If selection = DialogResult.OK Then userSelectedPlayerFilePath = playerselected.FileName My.Settings.playerpath = playerselected.FileName My.Settings.Save() End If End Sub ' Play button Public Sub C1Button2_Click(sender As Object, e As EventArgs) Handles C1Button2.Click Process.Start(userSelectedPlayerFilePath, winampargs) End Sub #End Region
Código
End Class




