-
Jan 26th, 2014, 01:54 PM
#1
Thread Starter
PowerPoster
[VB2010] - how 'click' on a button from code?
i'm on load form. but before show the form, i'm testing some data.
i open the print form, but how can i 'activate' the click event from a button?
i did:
Code:
If a = MsgBoxResult.Yes Then
frmInserirDadosVeiculo.ShowDialog()
m_rowPosition = i
frmInserirDadosVeiculo.btnImprimir.PerformClick()
frmInserirDadosVeiculo.Close()
End If
the form is showed, but not clicked
seems to be ignored, why?
-
Jan 26th, 2014, 02:17 PM
#2
Re: [VB2010] - how 'click' on a button from code?
the problem is the ShowDialog call. all the code after is not executed until after the dialog form is closed.
try putting the code in the form_shown event of frmInserirDadosVeiculo
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 26th, 2014, 02:42 PM
#3
Thread Starter
PowerPoster
Re: [VB2010] - how 'click' on a button from code?
Originally Posted by .paul.
the problem is the ShowDialog call. all the code after is not executed until after the dialog form is closed.
try putting the code in the form_shown event of frmInserirDadosVeiculo
sorry but i need more information
you have right... i need give time to cpu for show the form correctly and then call the click event.
see my loop:
Code:
'testing the values before do something
Dim i As Integer
Dim s As Date = Date.Parse(m_DataTable.Rows(m_rowPosition)("InspecaoData"))
For i = 0 To m_DataTable.Rows.Count - 1
If DateDiff("d", s, Date.Now) <= 6 Then
Dim a As MsgBoxResult
a = MsgBox("O carro com a matricula: " & m_DataTable.Rows(m_rowPosition)("IDMatricula").ToString() & " Tem que ir á inspeçao até: " & m_DataTable.Rows(m_rowPosition)("InspecaoData").ToString() & vbNewLine & "Deseja imprimir os dados do veiculo?", MsgBoxStyle.YesNo, "Informação automatica")
If a = MsgBoxResult.Yes Then
m_rowPosition = i
data = dados.Imprimir
frmInserirDadosVeiculo.ShowDialog()
frmInserirDadosVeiculo.btnImprimir.PerformClick()
frmInserirDadosVeiculo.Close()
End If
End If
Next
everytime that the user needs print the doc, the form is showed, then print what it's there(that button click event) and then close the form.
please give me more information
-
Jan 26th, 2014, 02:45 PM
#4
Re: [VB2010] - how 'click' on a button from code?
frmInserirDadosVeiculo.ShowDialog()
frmInserirDadosVeiculo.btnImprimir.PerformClick()
frmInserirDadosVeiculo.Close()
the code executes the highlighted line.
the next line + any lines after that are not executed until frmInserirDadosVeiculo is closed
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 26th, 2014, 02:48 PM
#5
Thread Starter
PowerPoster
Re: [VB2010] - how 'click' on a button from code?
Originally Posted by .paul.
frmInserirDadosVeiculo.ShowDialog()
frmInserirDadosVeiculo.btnImprimir.PerformClick()
frmInserirDadosVeiculo.Close()
the code executes the highlighted line.
the next line + any lines after that are not executed until frmInserirDadosVeiculo is closed
so the on frmInserirDadosVeiculo form load event i can compire it:
data = dados.Imprimir
and call the button printer, right
-
Jan 26th, 2014, 03:00 PM
#6
Re: [VB2010] - how 'click' on a button from code?
seems i'm unable to convey this to you in English, so here's some code:
Code:
Public Class frmInserirDadosVeiculo
Private Sub frmInserirDadosVeiculo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'whatever code you have in frmInserirDadosVeiculo_Load
End Sub
Private Sub frmInserirDadosVeiculo_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
btnImprimir.PerformClick()
End Sub
Private Sub btnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprimir.Click
'whatever code you have in btnImprimir_Click
Me.DialogResult = Windows.Forms.DialogResult.OK 'closes dialog
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 26th, 2014, 03:05 PM
#7
Thread Starter
PowerPoster
Re: [VB2010] - how 'click' on a button from code?
Originally Posted by .paul.
seems i'm unable to convey this to you in English, so here's some code:
Code:
Public Class frmInserirDadosVeiculo
Private Sub frmInserirDadosVeiculo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'whatever code you have in frmInserirDadosVeiculo_Load
End Sub
Private Sub frmInserirDadosVeiculo_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
btnImprimir.PerformClick()
End Sub
Private Sub btnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprimir.Click
'whatever code you have in btnImprimir_Click
Me.DialogResult = Windows.Forms.DialogResult.OK 'closes dialog
End Sub
End Class
i did something like that. now i can't test moro, because i lose the black cartiger(color)
but i will in try in other time.. thanks for all
-
Jan 26th, 2014, 03:10 PM
#8
Thread Starter
PowerPoster
Re: [VB2010] - how 'click' on a button from code?
i will change for another thot, that will print normaly
instead use the msgbox() i will show the dialog and the user can cancel or print
thanks for all
-
Jan 26th, 2014, 03:38 PM
#9
Thread Starter
PowerPoster
Re: [VB2010] - how 'click' on a button from code?
Originally Posted by joaquim
i will change for another thot, that will print normaly
instead use the msgbox() i will show the dialog and the user can cancel or print
thanks for all
i mean for these:
Code:
'testing the values before do something
Dim i As Integer
Dim s As Date
For i = 0 To m_DataTable.Rows.Count - 1
s = Date.Parse(m_DataTable.Rows(m_rowPosition)("InspecaoData"))
If DateDiff("d", s, Date.Now) <= 6 Then
m_rowPosition = i
data = dados.Imprimir
frmInserirDadosVeiculo.ShowDialog()
End If
Next
like you said, the for don't increment, before the form be closed
-
Jan 26th, 2014, 04:51 PM
#10
Re: [VB2010] - how 'click' on a button from code?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|