Jump to content

Recommended Posts

Posted

Gostaria de activar um botao por codigo em VB.NET...

Sei k iss é possivel em vb6 e k fazia assim:

(Exemplo)
If text1=50 then
command1.value=1
end if

O problema é k n consigo fazer isto no VB.NET pk n existe o comando VALUE para os botoes...  😛

Kual é o k se deve utilizar?  :wallbash:

Cumps [[ ]]

Posted

Não sei se é isto que queres, mas em principio deve haver um "enabled"  que activa ou descativa o butão,  button.Enabled = True; 

😛

Engenharia de Redes e Sistemas Informáticos, DCC-FCUP. www.dcc.fc.up.pt

Posted
Não sei se é isto que queres, mas em principio deve haver um "enabled"  que activa ou descativa o butão,  button.Enabled = True; 

Nepia o enabled é pra deixa ser clikado ou n... n sabs mm mais nd? =\

Cumps [[ ]]

Posted

hummmm mas o k é k tu entendes por activar? executar a função como se clickasses no butão?

Engenharia de Redes e Sistemas Informáticos, DCC-FCUP. www.dcc.fc.up.pt

Posted

hummm se nao tem nenhuma função na class Button , entao provavelmente tens k chamar a função k activa o butão

do tipo:  onButton1_click(...) , nao me recordo bem mas normalmente funciona assim lol

Engenharia de Redes e Sistemas Informáticos, DCC-FCUP. www.dcc.fc.up.pt

Posted

pois exatamente e eu fz iss mas tb n deu fiz assim:

If textbox1.text = 10 Then

            Button1_Click(Nothing, Nothing)

        End If

mas n da ta a dar erro... =\

diz isto:

Error 13 'WebMail.Form2.Private Sub btnSend_Click(sender As Object, e As System.EventArgs)' is not accessible in this context because it is 'Private'.

Posted

hummm tas aceder a um metodo privado da class Webmail.form1. a função Button1_Click() pertence a ke class?  é pah mas nao existe button1.Button1_Click ou button1.Click?

Engenharia de Redes e Sistemas Informáticos, DCC-FCUP. www.dcc.fc.up.pt

Posted

Epah n ha nd...

Ja tentei o comand BUTTON1.SELECT e nd, plos vistos iss funka como um FOCUS pk n carrega no botao só o "ilumina" como selecionado

JA tentei o comand BUTTON1.PREFORMCLICK e nd tb....

e das classes n sei... so sei k o botao ta noutr form... o codigo original é este:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text = 20 Then
            ProgressBar1.Value = ProgressBar1.Value + 10
            If ProgressBar1.Value = 100 Then
                Timer1.Enabled = False
                Button2.Enabled = True
            End If
            If TextBox2.Text = 30 Then
              [[  Form2.btnSend.Select() ]] --> AKI É K N FUNKA
            End If
        End If
    End Sub

n sei pk eles tiraram o command VALUE dos botoes akilo era um espetaculo lol...

Posted

vamos la ver se eu entendi bem

se o q queres q aconteça é q o valor quando chega a 30, o botão seja clicado automaticamente para executar as funções q estão dentro desse evento, porq não metes o codigo q esta dentro do OnClick dentro de uma função quando clicas no botão chamas essa função e quando o valor é igual a 30 chamas tambem essa função....????

penso q seja isso que pretendes... :smoke:

Posted

pois exatamente e eu fz iss mas tb n deu fiz assim:

If textbox1.text = 10 Then

            Button1_Click(Nothing, Nothing)

        End If

mas n da ta a dar erro... =\

diz isto:

Error 13 'WebMail.Form2.Private Sub btnSend_Click(sender As Object, e As System.EventArgs)' is not accessible in this context because it is 'Private'.

Tens de mudar a função para Public para que possas aceder à mesma.

Quando declaras o "Sub" dizes se é "Private" (privado) ou "Public" (Publico).

exemplo:

'Privado
Private Sub EXEMPLO()
End Sub

'Publico
Public Sub EXEMPLO()
End Sub

"Rejoice not against me, O mine enemy: when I fall, I shall arise; when I sit in darkness, the LORD shall be a light unto me." - Micah 7:8 (KJV)

Posted

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text = 50 Then
            Me.Button1.Focus()
            SendKeys.Send("{ENTER}")

        End If
    End Sub


Posted


    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text = 50 Then
            Me.Button1.Focus()
            SendKeys.Send("{ENTER}")

        End If
    End Sub


LOL

Não é mais facil usar

Button1.PerformClick();

Fikem Bem!!!Miguel Duarte - (SoulOnFire)O meu BLOG - XAML E WPF - http://wpfpt.wordpress.com/

Posted

Ou o InvokeOnClick()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("TESTE")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.InvokeOnClick(Button1, e)
    End Sub
Posted

Brigado! Funkou  😉  😛   😄

Usei o codigo do SoulOnFire:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text = 50 Then
            Me.Button1.Focus()
            SendKeys.Send("{ENTER}")

        End If
    End Sub

O preformClick ja tinha esperimentado e n tava a dar... n sei se era pra essa accao se funkava pra outra cena... sei k n carregou no botao...

Cumps e obrigadao pla paciencia [[[ ]]]

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.