Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27199

VS 2010 Detect keypress within another event

$
0
0
hello again people. I would like your expertise in this matter here. I'm having the following sub that adds calendar items in the database.

Code:

    Private Sub VisitCalendar_ItemCreating(sender As Object, e As System.Windows.Forms.Calendar.CalendarItemCancelEventArgs) Handles VisitCalendar.ItemCreating
        'το event αυτό είναι η λύση για την δημιουργία calendar item μέσω του context menu...
        Try
            If Not PersonIDfromGridSelection = Nothing Then

                sqlComm = "INSERT INTO [50_Visits] " _
                            & "(VisitID, PersonID, VisitDate, VisitTime, VisitType, UrgentFlag, CompleteFlag) " _
                            & "VALUES " _
                            & "(@ID, @PersonID,@VisitDate,@VisitTime,@VisitType, 'N', 'N')"
                Dim Command As New SqlCommand(sqlComm, Connection)

                With Command.Parameters
                    .Add(New SqlParameter("@ID", ReturnNextStr(LatestPKRecord("VisitID", "50_Visits"))))
                    .Add(New SqlParameter("@PersonID", PersonIDfromGridSelection))
                    .Add(New SqlParameter("@VisitDate", Format(CDate(e.Item.Date), "yyyy-MM-dd"))) 'Format(CDate(Appointment.AppointmentDateMasked.Text), "yyyy-MM-dd")
                    .Add(New SqlParameter("@VisitTime", Format(CDate(e.Item.Date), "HH:mm")))
                    .Add(New SqlParameter("@VisitType", e.Item.Text))
                End With

                Command.ExecuteNonQuery()
                'εδώ ξανατρέχω το query ώστε να πάρει το tag το item για reference και για να μην κάνει κλονγκ το πρόγραμμα....
                sqlComm = "SELECT TOP 1 VisitID FROM [50_Visits] ORDER BY VisitID DESC"
                Command.CommandText = sqlComm
                e.Item.Tag = Command.ExecuteScalar.ToString

                PersonIDfromGridSelection = Nothing

                ConnClose()
            Else
            End If

        Catch ex As Exception
            MsgBox("Ένα ή παραπάνω πεδία δεν έχουν συμπληρωθεί" & vbCrLf & "ή έχει γίνει λάθος κατά την πληκτρολόγηση." & vbCrLf &
                  "Παρακαλώ ελέγξτε τα πεδία και ξαναπροσπαθήστε.")

        End Try

    End Sub

The problem is that when i type something (item.text) the control does not take the whole string to update the database but only the first letter. So what i'm trying to do is to detect a keypress event withing the sub shown above.
any ideas ?

thank you in advance.

Viewing all articles
Browse latest Browse all 27199

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>