الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

استفسار عند ضغط Enter فى الداتا جريد

بدأه الكومندا المهم في 27 ديسمبر 2008 · 8 رد · 878 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

اولا اشكر كل الاخوة فى هذا المنتدى الرائع على المجهود الجبار المبذول منهم

ولى سؤال مهم جدا

انا بعمل فى مشروع

واريد عند الضغط على مفتاح ENTER ينتقل الى الخلية التالية وليس السطر التالى

انا بحثت عن الكود ولما تمت تجربته وجدة يعمل يعمل ولكن يعمل على شكل TAB ولا يتوقف عندButton

مرفق المثال

WindowsApplication3.rar

#2

انا مابصتش على الكود بس ممكن اقولك حاجة ممكن تساعدك على التفكير

ايه رايك وانت بتدوس انتر تعرف رقم العمود اللي انت واقف عليه

ولو طلع اخر عمود ضيف صف جديد وابدأ من الأول

او لو طلع اخر عمود اعمل Exit sub وخليك على نفس العمود او ابدأ من اول عمود مرة اخرة

تم تعديل هذه المشاركة بواسطة MohamedAliSalim في 27 ديسمبر 2008 في 16:22

Mohamed Ali Salim

0.1..0...4....7.....6......2.......7........4.........8

#3
MohamedAliSalim كتب:
انا مابصتش على الكود بس ممكن اقولك حاجة ممكن تساعدك على التفكير

ايه رايك وانت بتدوس انتر تعرف رقم العمود اللي انت واقف عليه

ولو طلع اخر عمود ضيف صف جديد وابدأ من الأول

او لو طلع اخر عمود اعمل Exit sub وخليك على نفس العمود او ابدأ من اول عمود مرة اخرة

شكرا على اهتمامك بالموضوع بس انا مش فاهم قصدك يا ريت ترفق كلامك بمثال ولك كل الشكر

#4

ايه يا جماعة هو السؤوال صعب ولا ايه ولا الناس مش مهتمه غير بالمواضيع اللى فيها اكواد بس

تم تعديل هذه المشاركة بواسطة الكومندا المهم في 29 ديسمبر 2008 في 20:30

#5

مرحباً .

ليس الأفضل لكنه يعمل :

Private Sub DataGridView1_KeyPress(ByVal Sender As Object, ByVal E As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress

If E.KeyChar = Chr(13) Then

If DataGridView1.SelectedCells.Count > 0 Then

Dim CL As DataGridViewCell = DataGridView1.SelectedCells(0)

Dim C, R As Integer

C = CL.ColumnIndex + 1

R = CL.RowIndex - 1

If R = -1 Then R = (DataGridView1.Rows.Count - 1)

If R >= (DataGridView1.Rows.Count - 1) And C > (DataGridView1.Columns.Count - 1) Then

C = 0

R = 0

ElseIf R > (DataGridView1.Rows.Count - 1) Then

R = 0

ElseIf C > (DataGridView1.Columns.Count - 1) Then

C = 0

R += 1

End If

DataGridView1.CurrentCell = DataGridView1.Rows®.Cells©

End If

E.Handled = True

End If

End Sub

استبدل الـ © بـ ( C )

والـ ® بـ ( R )

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 29 ديسمبر 2008 في 21:01

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#6

شكرا اخى الكريم على الكود وسوف اقوم بتجربه الكود

#7

لا شكر على واجب, آمل أن يقوم بالمطلوب :) .

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 4 يناير 2009 في 20:56

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#8
Bashar Rabat كتب:
مرحباً .

ليس الأفضل لكنه يعمل :

Private Sub DataGridView1_KeyPress(ByVal Sender As Object, ByVal E As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress

If E.KeyChar = Chr(13) Then

If DataGridView1.SelectedCells.Count > 0 Then

Dim CL As DataGridViewCell = DataGridView1.SelectedCells(0)

Dim C, R As Integer

C = CL.ColumnIndex + 1

R = CL.RowIndex - 1

If R = -1 Then R = (DataGridView1.Rows.Count - 1)

If R >= (DataGridView1.Rows.Count - 1) And C > (DataGridView1.Columns.Count - 1) Then

C = 0

R = 0

ElseIf R > (DataGridView1.Rows.Count - 1) Then

R = 0

ElseIf C > (DataGridView1.Columns.Count - 1) Then

C = 0

R += 1

End If

DataGridView1.CurrentCell = DataGridView1.Rows®.Cells©

End If

E.Handled = True

End If

End Sub

استبدل الـ © بـ ( C )

والـ ® بـ ( R )

شكرا يا اخى الكود يعمل بس لو كتبت شى فى اى عمود ينقل الى الاسفل اولا ثم يعود فى العمود الثانى فى نفس صف الكتابة

#9

مرحباً أخي الكريم .

اعتذر عن ذلك, لم احسب له حساب :( .

جرب التالي :

 

[color= #000000; font-weight: bold;]Public [color= #000000; font-weight: bold;]Class Form1

    [color= #000000; font-weight: bold;]Private Edited [color= #b1b100;]As Integer [color= #339933;]= [color= #cc66cc;]-5

    [color= #000000; font-weight: bold;]Private IsAuto [color= #b1b100;]As Boolean [color= #339933;]= [color= #000000; font-weight: bold;]True

 

    [color= #000000; font-weight: bold;]Private Sub DataGridView1_CellEndEdit[color= #009900;](ByVal Sender [color= #b1b100;]As Object[color= #339933;], [color= #990000;]_

ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].Windows[color= #339933;].Forms[color= #339933;].DataGridViewCellEventArgs[color= #009900;]) Handles DataGridView1[color= #339933;].CellEndEdit

        Edited [color= #339933;]= E[color= #339933;].RowIndex

        IsAuto [color= #339933;]= [color= #000000; font-weight: bold;]False

    [color= #990000;]End Sub

 

    [color= #000000; font-weight: bold;]Private Sub DataGridView1_KeyPress[color= #009900;](ByVal Sender [color= #b1b100;]As Object[color= #339933;], [color= #990000;]_

ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].Windows[color= #339933;].Forms[color= #339933;].KeyPressEventArgs[color= #009900;]) Handles DataGridView1[color= #339933;].KeyPress

        [color= #b1b100;]If E[color= #339933;].KeyChar [color= #339933;]= [color= #990000;]Chr[color= #009900;]([color= #cc66cc;]13[color= #009900;]) Then

            CheckSelected[color= #009900;]([color= #009900;])

            E[color= #339933;].Handled [color= #339933;]= [color= #000000; font-weight: bold;]True

        [color= #990000;]End [color= #b1b100;]If

    [color= #990000;]End Sub

 

    [color= #000000; font-weight: bold;]Private Sub CheckSelected[color= #009900;]([color= #009900;])

        IsAuto [color= #339933;]= [color= #000000; font-weight: bold;]True

        [color= #b1b100;]If Not DataGridView1[color= #339933;].CurrentRow[color= #339933;].IsNewRow Then

            [color= #b1b100;]If Not DataGridView1[color= #339933;].CurrentCell Is Nothing Then

                Dim CL [color= #b1b100;]As DataGridViewCell [color= #339933;]= DataGridView1[color= #339933;].CurrentCell

                Dim C[color= #339933;], R [color= #b1b100;]As Integer

                C [color= #339933;]= CL[color= #339933;].ColumnIndex [color= #339933;]+ [color= #cc66cc;]1

                R [color= #339933;]= CL[color= #339933;].RowIndex [color= #339933;]- [color= #cc66cc;]1

                [color= #b1b100;]If Edited [color= #339933;]> [color= #cc66cc;]-5 Then

                    R [color= #339933;]= Edited

                [color= #990000;]End [color= #b1b100;]If

                [color= #b1b100;]If R [color= #339933;]<= [color= #cc66cc;]-1 Then R [color= #339933;]= [color= #009900;](DataGridView1[color= #339933;].Rows[color= #339933;].[color= #990000;]Count [color= #339933;]- [color= #cc66cc;]1[color= #009900;])

                [color= #b1b100;]If R [color= #339933;]>= DataGridView1[color= #339933;].Rows[color= #339933;].[color= #990000;]Count And C [color= #339933;]> DataGridView1[color= #339933;].Columns[color= #339933;].[color= #990000;]Count Then

                    C [color= #339933;]= [color= #cc66cc;]0 [color= #339933;]: R [color= #339933;]= [color= #cc66cc;]0

                [color= #b1b100;]ElseIf R [color= #339933;]>= DataGridView1[color= #339933;].Rows[color= #339933;].[color= #990000;]Count Then [color= #339933;]: R [color= #339933;]= [color= #cc66cc;]0

                [color= #b1b100;]ElseIf C [color= #339933;]>= DataGridView1[color= #339933;].Columns[color= #339933;].[color= #990000;]Count Then [color= #339933;]: C [color= #339933;]= [color= #cc66cc;]0 [color= #339933;]: R [color= #339933;]+= [color= #cc66cc;]1

                [color= #990000;]End [color= #b1b100;]If

                DataGridView1[color= #339933;].CurrentCell [color= #339933;]= [color= #009900;](DataGridView1[color= #339933;].Rows[color= #009900;](R [color= #009900;])[color= #339933;].Cells[color= #009900;](C [color= #009900;])[color= #009900;])

            [color= #990000;]End [color= #b1b100;]If

            Edited [color= #339933;]= [color= #cc66cc;]-5

        [color= #990000;]End [color= #b1b100;]If

    [color= #990000;]End Sub

 

    [color= #000000; font-weight: bold;]Private Sub DataGridView1_SelectionChanged[color= #009900;](ByVal sender [color= #b1b100;]As Object[color= #339933;], [color= #990000;]_

ByVal e [color= #b1b100;]As [color= #990000;]System[color= #339933;].EventArgs[color= #009900;]) Handles DataGridView1[color= #339933;].SelectionChanged

        [color= #b1b100;]If Not IsAuto Then

            CheckSelected[color= #009900;]([color= #009900;])

        [color= #990000;]End [color= #b1b100;]If

    [color= #990000;]End Sub

 

[color= #990000;]End [color= #000000; font-weight: bold;]Class

تحياتي :) .

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 6 يناير 2009 في 14:43

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…