منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : جعل ال datagridview لا تقبل إلا إدخال نوع معين من البيانات
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم و رحمة الله و بركاته
بعد التحية
هل هناك طريقة لجعل الأداة datagridview لا تقبل الا إدخال نوع معين من البيانات ارقام مثلا أو عملة فى عمود أو Column معين؟
هذا كود لمشروع يتألف من فورم1 FORM1 فيه داتا جريد فيو اسمها DGV 
وهناك كودين لجعل العمود 1 والعمود2 لا يقبلان الا الارقام والفاصلة فقط
PHP كود :
Public Class Form1
    Dim column_index 
As Integer 0

    Private Sub DGV_EditingControlShowing
(ByVal sender As ObjectByVal e As System.Windows.Forms
.DataGridViewEditingControlShowingEventArgs)
 
Handles DGV.EditingControlShowing   

        Dim j 
As Integer DGV.CurrentCell.ColumnIndex


        If j 
Or 2 Then
            column_index 
DGV.CurrentCell().ColumnIndex

            Dim TextEdit 
As TextBox e.Control

            RemoveHandler TextEdit
.KeyPressAddressOf TextBox_KeyPress_Number
            AddHandler TextEdit
.KeyPressAddressOf TextBox_KeyPress_Number
        End 
If

 
   End Sub
    Public Sub TextBox_KeyPress_Number
(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyPressEventArgs)

 
       Dim j As Integer DGV.CurrentCell.ColumnIndex

        If j 
Or 2 Then
            Select 
Case column_index 0
                Case 0

If(e.KeyChar "0" OrElse e.KeyChar "9"AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar<> "." AndAlso e.KeyChar<> ","Then
                        e
.Handled True
                    End 
If


 
           End Select

        End 
If
 
    
    End Sub
End 
Class 
جزاكم الله خيرا و بارك فيكم