تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] استفسار :- بخصوص تغيير اسم ال Button بعد الضغط
#7


إذا كانت الأسطر كثيرة استخدم DataGridView بثلاث أعمدة TextBox وعمود رابع Button

وهذه كود الاستخدام إن شاء الله تكون واضحة
كود :
Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
   sender.EndEdit()
   If e.ColumnIndex = 3 Then
       Dim btn As DataGridViewButtonCell = sender.Item(e.ColumnIndex, e.RowIndex)
       If btn.FormattedValue = "Add" Then
           Add(sender.CurrentRow)
           'btn.Style.NullValue = "Update"
       Else
           Update(sender.CurrentRow)
           'btn.Style.NullValue = "Add"
       End If
   End If

End Sub

Private Sub Add(row As DataGridViewRow)
   row.Cells(3).Style.NullValue = "Update"
   Dim txt1 As String = TryCast(row.Cells(0).Value, String)
   Dim txt2 As String = TryCast(row.Cells(1).Value, String)
   Dim txt3 As String = TryCast(row.Cells(2).Value, String)
   MsgBox("Add Row: " & row.Index & vbNewLine & _
          "txt1: " & txt1 & vbNewLine & _
          "txt2: " & txt2 & vbNewLine & _
          "txt3: " & txt3)
End Sub

Private Sub Update(row As DataGridViewRow)
   row.Cells(3).Style.NullValue = "Add"
   Dim txt1 As String = TryCast(row.Cells(0).Value, String)
   Dim txt2 As String = TryCast(row.Cells(1).Value, String)
   Dim txt3 As String = TryCast(row.Cells(2).Value, String)
   MsgBox("Update Row: " & row.Index & vbNewLine & _
          "txt1: " & txt1 & vbNewLine & _
          "txt2: " & txt2 & vbNewLine & _
          "txt3: " & txt3)
End Sub
الرد }}}
تم الشكر بواسطة: dubai.eig , dubai.eig , elgokr , elgokr


الردود في هذا الموضوع
RE: استفسار :- بخصوص تغيير اسم ال Button بعد الضغط - بواسطة 911 - 16-09-18, 01:32 PM


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


يقوم بقرائة الموضوع: