السلام عليكم ورحمة الله وبركاته
وكا عام وانتم بالف خير
ممكن المساعدة في تحديد نقطة واحدة (فاصلة عشرية ) في كتابة الرقم في حقل ال 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
وبارك الله بكم
السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم... وكل عام وانتم بالف خير ...
واجهة مشكلة في كتابة الكود ...
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"
السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم...
ولكن لم تتحق النتيجة ...
(04-08-20, 02:51 PM)Mohammed Nafa كتب : [ -> ]السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم...
ولكن لم تتحق النتيجة ...
ارفق البرنامج نعدل عليه اذا امكن
الكود يعمل بدون اي مشاكل عندي
[
attachment=25382]
السطر ده تتحكم منه في اي عمود نحتاج ان نتحكم في مدخلات المستخدم
كود :
If DataGridView1.CurrentCell.ColumnIndex = 2 Then
انا في المثال ده عملته العمود اللي index بتاعه = 2
السلام عليكم ورحمة الله وبركاته
أشكر لكم مروركم...
وبارك الله بكم ....
الكود يعمل بشكل ممتاز ....