Crear botones en tiempo de ejecucion
Publicado por Joel Vanessa Ferreyra (12 intervenciones) el 22/09/2009 18:30:25
Hola a todos.Queria preguntarle si alguien me puede ayudar. Yo tengo una aplicacion a la cual me pidieron q le agrege un boton para que despues con el tiempo se pueda agregar, mas cosas.El problema es el siguiente cuando yo hago click en el boton agregar, se abre el cuadro de dialogo para seleccionar una carpeta, hago clic en aceptar y me crea el boton ademas de hacer otras cosas, "cuando yo vuelvo hacer lo mismo click en el boton agregar y elegir otra carpeta, para agregar en lugar de crearme otro boton debajo del creado anteriormente, m lo reemplaza. Alguien m puede ayudar.Gracias
El código seria:
Private Sub btnselectorCARPETA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnselectorCARPETA.Click
txTCARPETA.Text = " "
ListBox1.Items.Clear()
If dlgseleccionarCARPETA.ShowDialog() = Windows.Forms.DialogResult.OK Then
RUTACARPETA = dlgseleccionarCARPETA.SelectedPath
NOMBRECARPETA = My.Computer.FileSystem.GetName(RUTACARPETA)
txTCARPETA.Text = NOMBRECARPETA
If Not ListBox1.SelectedItem = " " Then
'Me.botonagregado.Name = "Btn" & AGREGAR.txTCARPETA.Text
'Me.botonagregado.Text = txTCARPETA.Text
'AddHandler Me.botonagregado.Click, AddressOf ejecutar
'Me.botonagregado.Location = New Point(txtpoint.X + 10, txtpoint.Y)
'txtpoint.Y += botonagregado.Height + 15
'Me.Controls.Add(botonagregado)
End If
End If
El código seria:
Private Sub btnselectorCARPETA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnselectorCARPETA.Click
txTCARPETA.Text = " "
ListBox1.Items.Clear()
If dlgseleccionarCARPETA.ShowDialog() = Windows.Forms.DialogResult.OK Then
RUTACARPETA = dlgseleccionarCARPETA.SelectedPath
NOMBRECARPETA = My.Computer.FileSystem.GetName(RUTACARPETA)
txTCARPETA.Text = NOMBRECARPETA
If Not ListBox1.SelectedItem = " " Then
'Me.botonagregado.Name = "Btn" & AGREGAR.txTCARPETA.Text
'Me.botonagregado.Text = txTCARPETA.Text
'AddHandler Me.botonagregado.Click, AddressOf ejecutar
'Me.botonagregado.Location = New Point(txtpoint.X + 10, txtpoint.Y)
'txtpoint.Y += botonagregado.Height + 15
'Me.Controls.Add(botonagregado)
End If
End If
Valora esta pregunta


0