تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[تم الحل] كيف اخلي هاندلس ل Button انشاتة بكود
#6
(05-02-20, 09:08 PM)Sorax كتب : اعتذر بس اريد الكود نفس هذا وتكون الهاندلس شغاله
لان كودك الاخير بيه خطا
كود :
  Private Sub Formx_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       For i As Integer = 0 To 3
           Dim Btnx As Button = New Button
           With Btnx
               Btnx.Location = New System.Drawing.Point(5, 85)
               Btnx.Text = "Send"
               Btnx.Name = "Btnx" & (i + 1).ToString
               Btnx.BackColor = System.Drawing.Color.White
               Btnx.Size = New System.Drawing.Size(100, 25)
           End With
           Dim Panx As Panel = New Panel
           With Panx
               Panx.BackColor = System.Drawing.Color.Silver
               Panx.Size = New System.Drawing.Size(111, 111)
           End With
           Dim Picx As PictureBox = New PictureBox
           With Picx
               Picx.Location = New System.Drawing.Point(30, 5)
               Picx.Size = New System.Drawing.Size(50, 50)
               Picx.BackColor = System.Drawing.Color.White
           End With
           Dim Labx As Label = New Label
           With Picx
               Labx.Location = New System.Drawing.Point(0, 63)
               Labx.Size = New System.Drawing.Size(111, 15)
               Labx.Text = "{NAME}"
               Labx.TextAlign = System.Drawing.ContentAlignment.TopCenter
           End With
           Panx.Controls.Add(Btnx)
           Panx.Controls.Add(Picx)
           Panx.Controls.Add(Labx)
           FlowLayoutPanel1.Controls.Add(Panx)
       Next
       ' هنا نضيف الحدث لكل باتون

       For Each b As Button In Me.Controls.OfType(Of Button)()
           AddHandler b.Click, AddressOf Btnx_Click
       Next
   End Sub
   Private Sub Btnx_Click(sender As Object, e As EventArgs)
       ' اكتب ما تريده في الحدث
       ' هنا نختار الباتون بناء علي التكست الخاص به
       ' ثم نحدد ما يجب أن يحدث عند الضغط علي الباتون
       Dim Btnx As Button = CType(sender, Button)
       Select Case Btnx.Name
           Case "Btnx1"
               Text = "Sorax"

           Case "Btnx2"


           Case "Btnx3"


           Case "Btnx4"
               Close()




       End Select

   End Sub

لم تحدد الاخطاء

اخي هو الان مجرب امامي ويعمل بدون اخطاء تفضل نسخ كالم الكود من المشروع الذي امامي الان
ولصق هنا ولا تنس ان تضيف اداة FlowLayoutPanel1
كود :
Public Class Form2


   Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Me.DataGridView1.Columns(1).Visible = False
       For i = 0 To 3

           Dim Panx As New Panel
           Panx.Size = New Size(111, 111)
           Panx.BackColor = Color.Silver
           FlowLayoutPanel1.Controls.Add(Panx)

           Dim Picx As New PictureBox
           Picx.Size = New Size(50, 50)
           Picx.Location = New Point(30, 5)
           Picx.BackColor = Color.White
           Panx.Controls.Add(Picx)

           Dim Labx As New Label
           Labx.Size = New Size(111, 15)
           Labx.Location = New Point(0, 63)
           Labx.Text = "{NAME}"
           Labx.TextAlign = ContentAlignment.TopCenter
           Panx.Controls.Add(Labx)

           Dim Btnx As New Button
           Btnx.Size = New Size(100, 25)
           Btnx.Location = New Point(5, 85)
           Btnx.Name = "Btnx" & (i + 1).ToString
           Btnx.BackColor = Color.White
           Btnx.Text = "Send"
           AddHandler Btnx.Click, AddressOf Btnx_Click
           Panx.Controls.Add(Btnx)

       Next

    End Sub


   Private Sub Btnx_Click(sender As Object, e As EventArgs)
       ' اكتب ما تريده في الحدث
       ' هنا نختار الباتون بناء علي التكست الخاص به
       ' ثم نحدد ما يجب أن يحدث عند الضغط علي الباتون
       Dim Btnx As Button = CType(sender, Button)
       Select Case Btnx.Name
           Case "Btnx1"
               Text = "Sorax"

           Case "Btnx2"

           Case "Btnx3"

           Case "Btnx4"
               Close()

       End Select

   End Sub

End Class
الرد }}}
تم الشكر بواسطة: asemshahen5 , asemshahen5 , Sorax , bidaya


الردود في هذا الموضوع
RE: كيف اخلي هاندلس ل BUtton انشاتة بكود - بواسطة alsalamoni - 05-02-20, 09:12 PM


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


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