تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] اريد جعل مساج بوكس في مصفوفة داخل class واناديها من فورم أخرى
#2
الطريقه عملت لها مثال بالمرفق  ،///  طبعا غير اسماء الحقول من  textbox1  , textbox2  الى الحقول الخاصه بك


.rar   WindowsApplication2.rar (الحجم : 48.25 ك ب / التحميلات : 51)

اذا لم تفهم جزء ساشرحه لك  ،،  سأقوم بوضع الاكواد هنا لما اراد القراءة بدون تنزيل المرفق :

الكلاس العام  :

كود :
Public Class MoveNextClass


    Public Shared Sub checkText(ByVal TargetForm As Form)
        For Each ctrl As Control In TargetForm.Controls
            If TypeOf ctrl Is TextBox Then
                If ctrl.Name = "TextBox1" And ctrl.Text = Nothing Then
                    MsgBox("  يجب أدخال الاسم واللقب ")
                    ctrl.Focus()
                    Exit Sub
                End If

                If ctrl.Name = "TextBox2" And ctrl.Text = Nothing Then
                    MsgBox("يجب أدخال العنوان")
                    ctrl.Focus()
                    Exit Sub
                End If


                If ctrl.Name = "TextBox3" And ctrl.Text = Nothing Then
                    MsgBox("  يجب أدخال رقم الهاتف")
                    ctrl.Focus()
                    Exit Sub
                End If


                If ctrl.Name = "TextBox4" And ctrl.Text = Nothing Then
                    MsgBox("يجب أدخال الوظيفة")
                    ctrl.Focus()
                    Exit Sub
                End If

            End If
        Next
    End Sub


    ''' <summary>
    ''' للانتقال الى الحقل التالي عند الضغط على انتر
    ''' </summary>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Shared Sub gotoNextControl(ByVal TargetForm As Form, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If Char.IsControl(e.KeyChar) Then
            If e.KeyChar.Equals(Chr(Keys.Return)) Then
                TargetForm.SelectNextControl(TargetForm.ActiveControl, True, True, True, False)
                e.Handled = True
            End If
        End If


    End Sub

End Class



طريقة استخدام الكلاس  :


كود :
Imports System.Security.Cryptography
Imports System.Text

Public Class Form1
    Private Sub Fields_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress, TextBox5.KeyPress, TextBox4.KeyPress, TextBox3.KeyPress, TextBox2.KeyPress, TextBox1.KeyPress
        Call MoveNextClass.gotoNextControl(Me, e)
    End Sub

 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MoveNextClass.checkText(Me)
    End Sub
End Class
اسم معرفي : محمد يحيى
الرد }}}
تم الشكر بواسطة: biloo20


الردود في هذا الموضوع
RE: اريد جعل مساج بوكس في مصفوفة داخل class واناديها من فورم أخرى - بواسطة myalsailamy - 15-03-16, 10:56 PM


التنقل السريع :


يقوم بقرائة الموضوع: