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

نسخة كاملة : سلام شباب محتاج مساعدة إذا أمكن
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
أرجو المساعدة لتحويل هذا الكود إلى لغة السي شارب :
    Private Sub DGV_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DGV.EditingControlShowing
        Dim i As Integer = DGV.CurrentCell.RowIndex
        Dim j As Integer = DGV.CurrentCell.ColumnIndex
        If j = 3 Or j = 4 Then
            column_index = DGV.CurrentCell().ColumnIndex
            Dim TextEdit As TextBox = e.Control
            RemoveHandler TextEdit.KeyPress, AddressOf TextBox_KeyPress_Number
            AddHandler TextEdit.KeyPress, AddressOf TextBox_KeyPress_Number
        End If
    End Sub
    Public Sub TextBox_KeyPress_Number(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Dim i As Integer = DGV.CurrentCell.RowIndex
        Dim j As Integer = DGV.CurrentCell.ColumnIndex
        If j = 3 Or j = 4 Then
            Select Case column_index = 0
                Case 0
                    If (e.KeyChar >= "a" And e.KeyChar <= "z") Or (e.KeyChar >= "A" And e.KeyChar <= "Z") Or (e.KeyChar >= "ا" And e.KeyChar <= "ي") Then
                        e.Handled = True
                    End If
            End Select
        End If
   End Sub
تفضل اخى aloush

كود :
   Private void DGV_EditingControlShowing(Object sender, System.Windows.Forms.DataGridViewEditingControlShowingEventArgs e)
   {
       int i = DGV.CurrentCell.RowIndex;
       int j = DGV.CurrentCell.ColumnIndex;
       If (j == 3 | j == 4)
       {
           column_index = DGV.CurrentCell().ColumnIndex;
           TextBox TextEdit = e.Control;
           TextEdit.KeyPress -= TextBox_KeyPress_Number;
           TextEdit.KeyPress += TextBox_KeyPress_Number;
       }
   }

   Public void TextBox_KeyPress_Number(Object sender, System.Windows.Forms.KeyPressEventArgs e)
   {
       int i = DGV.CurrentCell.RowIndex;
       int j = DGV.CurrentCell.ColumnIndex;
       If (j == 3 | j == 4)
       {
           switch (column_index == 0)
           {
               Case 0 :
                   {
                       If ((e.KeyChar >= "a" & e.KeyChar <= "z") | (e.KeyChar >= "A" & e.KeyChar <= "Z") | (e.KeyChar >= "ا" & e.KeyChar <= "ي"))
                           e.Handled = true;
                       break;
                   }
           }
       }
   }

تحياتى لك
وتمنياتى لك التوفيق
(18-06-18, 03:22 AM)elgokr كتب : [ -> ]
تفضل اخى aloush

كود :
   Private void DGV_EditingControlShowing(Object sender, System.Windows.Forms.DataGridViewEditingControlShowingEventArgs e)
   {
       int i = DGV.CurrentCell.RowIndex;
       int j = DGV.CurrentCell.ColumnIndex;
       If (j == 3 | j == 4)
       {
           column_index = DGV.CurrentCell().ColumnIndex;
          text.TextBox TextEdit = e.Control;
           TextEdit.KeyPress -= TextBox_KeyPress_Number;
           TextEdit.KeyPress += TextBox_KeyPress_Number;
       }
   }

   Public void TextBox_KeyPress_Number(Object sender, System.Windows.Forms.KeyPressEventArgs e)
   {
       int i = DGV.CurrentCell.RowIndex;
       int j = DGV.CurrentCell.ColumnIndex;
       If (j == 3 | j == 4)
       {
           switch (column_index == 0)
           {
               Case 0 :
                   {
                       If ((e.KeyChar >= "a" & e.KeyChar <= "z") | (e.KeyChar >= "A" & e.KeyChar <= "Z") | (e.KeyChar >= "ا" & e.KeyChar <= "ي"))
                           e.Handled = true;
                       break;
                   }
           }
       }
   }

تحياتى لك
وتمنياتى لك التوفيق
مشكور اخي الفاضل بس واجهني مشاكل هذا الكود و تم حلها اكتشفت شغلة مهمة بهذا الكود  : لازم تضيف  e.Control.text
الشكر لله

تحياتى لك
وتمنياتى لك التوفيق
Private void DGV_EditingControlShowing(Object sender, System.Windows.Forms.DataGridViewEditingControlShowingEventArgs e)
{
int i = DGV.CurrentCell.RowIndex;
int j = DGV.CurrentCell.ColumnIndex;
If (j == 3 | j == 4)
{
column_index = DGV.CurrentCell().ColumnIndex;
text.TextBox TextEdit = e.Control;
TextEdit.KeyPress -= TextBox_KeyPress_Number;
TextEdit.KeyPress += TextBox_KeyPress_Number;
}
}

Public void TextBox_KeyPress_Number(Object sender, System.Windows.Forms.KeyPressEventArgs e)
{
int i = DGV.CurrentCell.RowIndex;
int j = DGV.CurrentCell.ColumnIndex;
If (j == 3 | j == 4)
{
switch (column_index == 0)
{
Case 0 :
{
If ((e.KeyChar >= "a" & e.KeyChar <= "z") | (e.KeyChar >= "A" & e.KeyChar <= "Z") | (e.KeyChar >= "ا" & e.KeyChar <= "ي"))
e.Handled = true;
break;
}
}
}
}
سبحان الله وبحمده سبحان الله العظيم خالق السماء والارض خالق قانون التراحم بين عباده