تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تحديد نقطة واحدة dot في حقل ال datagridview
#1
السلام عليكم ورحمة الله وبركاته
وكا عام وانتم بالف خير
ممكن المساعدة في تحديد نقطة واحدة (فاصلة عشرية ) في كتابة الرقم في حقل ال datagridview ...فقد قمت بذلك في textbox كما يلي :
Private Sub textbox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles textbox1.KeyPress
        ' حدث كتابة أرقام فقط في الحقل
      
        If Asc(e.KeyChar) <> 8 Then
            If Asc(e.KeyChar) < 46 Or Asc(e.KeyChar) > 57 Then
                e.Handled = True
            End If
        End If
        If textbox1.Text.Contains(".") Then
            If e.KeyChar = "." Then
                e.Handled = True
            End If
        End If
    End Sub
كيف يمكن ذلك في حق ال datagridview
وبارك الله بكم
الرد }}}
تم الشكر بواسطة:
#2
كود :
Private Sub DataGridView1_GotFocus(sender As Object, e As EventArgs) Handles DataGridView1.GotFocus
    RemoveHandler CType(sender, DataGridView).EditingControlShowing, AddressOf DataGridView1_EditingControlShowing
    AddHandler CType(sender, DataGridView).EditingControlShowing, AddressOf DataGridView1_EditingControlShowing
End Sub
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
    If sender.CurrentCell.ColumnIndex = 0 Then ' <<<< ColumnIndex
        Dim TB = CType(e.Control, TextBox)
        RemoveHandler TB.KeyPress, AddressOf DataGridView1_KeyPress
        AddHandler TB.KeyPress, AddressOf DataGridView1_KeyPress
    End If
End Sub
Private Sub DataGridView1_KeyPress(sender As Object, e As KeyPressEventArgs)
    ' حدث كتابة أرقام فقط في الحقل

    If Asc(e.KeyChar) <> 8 Then
        If Asc(e.KeyChar) < 46 Or Asc(e.KeyChar) > 57 Then
            e.Handled = True
        End If
    End If
    If sender.Text.Contains(".") Then
        If e.KeyChar = "." Then
            e.Handled = True
        End If
    End If
End Sub
الرد }}}
تم الشكر بواسطة: WaeLx , WaeLx
#3
السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم... وكل عام وانتم بالف خير ...
واجهة مشكلة في كتابة الكود ...
Private Sub DGVewItems_KeyPress(sender As Object, e As KeyPressEventArgs) Handles DGVewItems.KeyPress
If Asc(e.KeyChar) <> 8 Then
If Asc(e.KeyChar) < 46 Or Asc(e.KeyChar) > 57 Then
e.Handled = True
End If
End If
If sender.Text.Contains(".") Then
If e.KeyChar = "." Then
e.Handled = True
End If
End If
End Sub
Private Sub DGVewItems_GotFocus(sender As Object, e As EventArgs) Handles DGVewItems.GotFocus
RemoveHandler sender.EditingControlShowing, AddressOf DGVewItems_EditingControlShowing
AddHandler sender.EditingControlShowing, AddressOf DGVewItems_EditingControlShowing
End Sub
Private Sub DGVewItems_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
If sender.CurrentCell.ColumnIndex = 13 Then ' <<<< ColumnIndex
Dim TB = CType(e.Control, TextBox)
RemoveHandler TB.KeyPress, AddressOf DGVewItems_KeyPress
AddHandler TB.KeyPress, AddressOf DGVewItems_KeyPress
End If
End Sub
أن كل من sender.EditingControlShowing و sender.EditingControlShowing يشار لها بالخطأ

class.system.object
supports all classes in the .net framework class hierarchy and providers low -level services to derived classes. this ultimate base class of classes in the .net framework it is the root of the type hierarchy . to browse the .net framework source code for this type , see the references source. "EditingControlShowing" is not an event of "Object"
الرد }}}
تم الشكر بواسطة:
#4
جرب هذا الكود :

كود :
   Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing

       RemoveHandler e.Control.KeyPress, AddressOf EditingControl_KeyPress
           AddHandler e.Control.KeyPress, AddressOf EditingControl_KeyPress


   End Sub
   Sub EditingControl_KeyPress(sender As Object, e As KeyPressEventArgs)
       Dim editingControl As Control = sender

       If DataGridView1.CurrentCell.ColumnIndex = 1 Then
           If (Not Char.IsControl(e.KeyChar)) Then
               If Not Regex.IsMatch(editingControl.Text + e.KeyChar, "^[-+]?\d*\.?\d*$") Then
                   e.Handled = True
               End If
           End If
       End If
   End Sub

https://stackoverflow.com/questions/1551...user-input
الرد }}}
تم الشكر بواسطة: asemshahen5 , عيد مبارك , عيد مبارك , WaeLx
#5
السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم...
ولكن لم تتحق النتيجة ...
الرد }}}
تم الشكر بواسطة:
#6
(04-08-20, 02:51 PM)Mohammed Nafa كتب : السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم...
ولكن لم تتحق النتيجة ...

ارفق البرنامج نعدل عليه اذا امكن
الرد }}}
تم الشكر بواسطة:
#7
كود :
Private Sub DGVewItems_KeyPress(sender As Object, e As KeyPressEventArgs) Handles DGVewItems.KeyPress
    If Asc(e.KeyChar) <> 8 Then
        If Asc(e.KeyChar) < 46 Or Asc(e.KeyChar) > 57 Then
            e.Handled = True
        End If
    End If
    If sender.Text.Contains(".") Then
        If e.KeyChar = "." Then
            e.Handled = True
        End If
    End If
End Sub
Private Sub DGVewItems_GotFocus(sender As Object, e As EventArgs) Handles DGVewItems.GotFocus
    RemoveHandler CType(sender, DataGridView).EditingControlShowing, AddressOf DGVewItems_EditingControlShowing
    AddHandler CType(sender, DataGridView).EditingControlShowing, AddressOf DGVewItems_EditingControlShowing
End Sub
Private Sub DGVewItems_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
    If sender.CurrentCell.ColumnIndex = 13 Then ' <<<< ColumnIndex
        Dim TB = CType(e.Control, TextBox)
        RemoveHandler TB.KeyPress, AddressOf DGVewItems_KeyPress
        AddHandler TB.KeyPress, AddressOf DGVewItems_KeyPress
    End If
End Sub
الرد }}}
تم الشكر بواسطة:
#8
(04-08-20, 02:19 PM)Anas Mahmoud كتب : جرب هذا الكود :

كود :
   Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing

       RemoveHandler e.Control.KeyPress, AddressOf EditingControl_KeyPress
           AddHandler e.Control.KeyPress, AddressOf EditingControl_KeyPress


   End Sub
   Sub EditingControl_KeyPress(sender As Object, e As KeyPressEventArgs)
       Dim editingControl As Control = sender

       If DataGridView1.CurrentCell.ColumnIndex = 13 Then '<<<<<<<< ColumnIndex
           If (Not Char.IsControl(e.KeyChar)) Then
               If Not Regex.IsMatch(editingControl.Text + e.KeyChar, "^[-+]?\d*\.?\d*$") Then
                   e.Handled = True
               End If
           End If
       End If
   End Sub

https://stackoverflow.com/questions/1551...user-input
الرد }}}
تم الشكر بواسطة: Mohammed Nafa , WaeLx
#9
الكود يعمل بدون اي مشاكل عندي

   

السطر ده تتحكم منه في اي عمود نحتاج ان نتحكم في مدخلات المستخدم

كود :
If DataGridView1.CurrentCell.ColumnIndex = 2 Then

انا في المثال ده عملته العمود اللي index بتاعه = 2


الملفات المرفقة
.zip   DataGridKeyPress.zip (الحجم : 54.32 ك ب / التحميلات : 9)
الرد }}}
تم الشكر بواسطة: Mohammed Nafa , عيد مبارك , WaeLx
#10
السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم...
وبارك الله بكم ....
الكود يعمل بشكل ممتاز ....
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  تعديل بيانات عمود DataGridView دفعة واحدة مصمم هاوي 2 164 05-03-24, 08:27 PM
آخر رد: مصمم هاوي
  فلترة datagridview بدون قاعدة بيانات صالح عبدالله 3 295 02-02-24, 04:07 PM
آخر رد: صالح عبدالله
  [VB.NET] ظهور التاريخ غير مرتب بالأقدم في datagridview مبرمج صغير 1 4 304 26-01-24, 03:41 PM
آخر رد: atefkhalf2004
  [VB.NET] التاريخ في أداة أبو سامر لطباعة DataGridView مبرمج صغير 1 17 629 26-01-24, 01:52 AM
آخر رد: مبرمج صغير 1
  مشكلة في datagridview Adata 4 310 17-01-24, 03:00 PM
آخر رد: aljzazy
Lightbulb [VB.NET] إطهار الصورة بمقاس معين في DataGridView أبو خالد الشكري 2 323 14-12-23, 03:01 PM
آخر رد: أبو خالد الشكري
Question [VB.NET] اسم عمود الأرقام في DataGridView أبو خالد الشكري 6 606 03-12-23, 08:01 AM
آخر رد: أبو خالد الشكري
  [VB.NET] Datagridview Slow حركة بطيئة waataanys 1 294 20-11-23, 04:33 PM
آخر رد: justforit
  [VB.NET] مطلوب دمج جملتين لتحديث قاعدة بيانات فى جملة واحدة AmeenRashed 1 335 18-11-23, 01:32 AM
آخر رد: sniper2030
  تحديد موقع ملف user.config واعدة توجيهه لموقع آخر Mohammed Nafa 3 439 07-11-23, 10:12 PM
آخر رد: Mohammed Nafa

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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم