تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[تم الحل] كيف اخلي هاندلس ل Button انشاتة بكود
#5
اعتذر بس اريد الكود نفس هذا وتكون الهاندلس شغاله
لان كودك الاخير بيه خطا
كود :
  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
الرد }}}
تم الشكر بواسطة: asemshahen5 , bidaya


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


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


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