ferreira12 Posted October 15, 2013 at 03:49 PM Report #529045 Posted October 15, 2013 at 03:49 PM (edited) Boas. Eu tenho 3 possiveis opçoes de escolha, ou seja vou ter 3 checkbox. quando clico numa queria que passa-se um certo atributo para o textbox. estou a tentar ainda mas sem resultado. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim str As String str = " " If CheckBox1.Checked = True Then str &= "teste" str &= TextBox1.Text End If If CheckBox2.Checked = True Then str &= CheckBox2.Text str &= " " End If If CheckBox3.Checked = True Then str &= CheckBox3.Text str &= " " End If End Sub Edited October 16, 2013 at 08:21 AM by ribeiro55
ferreira12 Posted October 15, 2013 at 03:59 PM Author Report #529046 Posted October 15, 2013 at 03:59 PM já consegui obrigado.
nelsonr Posted October 15, 2013 at 04:12 PM Report #529049 Posted October 15, 2013 at 04:12 PM já consegui obrigado. Se puderes coloca como resolveste, para que possa ajudar outros membros que tenham a mesma duvida
ferreira12 Posted October 15, 2013 at 04:23 PM Author Report #529054 Posted October 15, 2013 at 04:23 PM (edited) claro que sim Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox2.Clear() If CheckBox1.Checked = True Then TextBox2.Text = "teste" End If If CheckBox2.Checked = True Then TextBox2.Text = "teste2" uma questão existe a possibilidade de quando seleciono uma retirar o pisco da outra? Edited October 16, 2013 at 08:21 AM by ribeiro55
nelsonr Posted October 15, 2013 at 05:06 PM Report #529069 Posted October 15, 2013 at 05:06 PM Podes por CheckBox1.Checked = false
ferreira12 Posted October 15, 2013 at 05:10 PM Author Report #529071 Posted October 15, 2013 at 05:10 PM já experimentei isso e nao deu
nelsonr Posted October 15, 2013 at 05:17 PM Report #529074 Posted October 15, 2013 at 05:17 PM Podes mostrar o código onde colocaste?
ferreira12 Posted October 15, 2013 at 05:28 PM Author Report #529078 Posted October 15, 2013 at 05:28 PM (edited) Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click TextBox2.Clear() If CheckBox1.Checked = True Then CheckBox2.Checked = False CheckBox3.Checked = False TextBox2.Text = "teste1t" End If If CheckBox2.Checked = True Then CheckBox1.Checked = False CheckBox3.Checked = False TextBox2.Text = "teste2" End If If CheckBox3.Checked = True Then TextBox2.Text = "teste3" CheckBox2.Checked = False CheckBox1.Checked = False End If Edited October 16, 2013 at 08:21 AM by ribeiro55
nelsonr Posted October 15, 2013 at 05:33 PM Report #529079 Posted October 15, 2013 at 05:33 PM Se a checkbox 1 estiver ligada, vai sempre desligar as outras. O que deves querer fazer é ao clicar numa checkbox desligar as outras duas. Para isso deves fazer essa alteração no evento do CheckedChanged das checkboxs. Mas se for isso, não era melhor usares RadioButtons?
ferreira12 Posted October 15, 2013 at 05:41 PM Author Report #529081 Posted October 15, 2013 at 05:41 PM nunca utilizei RadioButtons, O método pra chamar é idêntico ao do checkbox?
nelsonr Posted October 15, 2013 at 08:36 PM Report #529096 Posted October 15, 2013 at 08:36 PM Sim, o funcionamento é semelhante às checkboxs, mas apenas permite estar uma ligada (ao ligares uma, desliga as outras do mesmo grupo)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now