ماهو كود منع ظهور نافذة باسم محدد لكن المتغير بخاصية label2.text
يعني مثلا لدي فورم باسم chat وضمن الادوات موجود ليبل يتغير محتواه بناء على قيمة في Listbox
فعند حدث ListBox1_MouseDoubleClick اريد كود يتحقق ان الليبل الموجودة بفورم معين تحمل نفس البند المحدد من Listbox فان كان نعم يتم تنشيط فورم الدردشة chat لنفس الاسم.
ارجو ان يكون السؤال واضح
وشكرا مقدما
نحمده ونصلي على رسوله الكريم
كود :
Private Sub listBox1_MouseDoubleClick(sender As Object, e As MouseEventArgs)
For Each f As Form In Application.OpenForms
If Break(f) Then
f.Activate()
Exit For
End If
Next
End Sub
Private Function Break(form As Form) As Boolean
For Each ctrl As Control In form.Controls
If TypeOf ctrl Is Label AndAlso ctrl.Text = listBox1.Text Then
Return True
End If
Next
Return False
End Function
بارك الله فيك
لكن الـ Listbox بفورم عرض المسجلين والليبل بفورم الدردشة
كود :
Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
' MsgBox(ListBox1.Text)
Dim chat As New chat
Dim gip As New SqlCommand("select uname,myip from tusers where uname='" & ListBox1.Text & "'", conn)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim dr As SqlDataReader = gip.ExecuteReader
If dr.Read Then
Try
chat.frindname.Text = ListBox1.Text
frindip = dr.Item("myip")
chat.Show()
Catch ex As Exception
MsgBox("هذا العضو لم يسجل دخوله ليتم تحديث معلومات الاتصال به", MsgBoxStyle.Critical, "")
End Try
End If
End Sub
جرب التالي:
كود :
Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
' MsgBox(ListBox1.Text)
dim stop as Boolean
For Each f As Form In Application.OpenForms
If Break(f) Then
f.Activate()
stop = true
Exit For
End If
Next
if stop then exit sub
Dim chat As New chat
Dim gip As New SqlCommand("select uname,myip from tusers where uname='" & ListBox1.Text & "'", conn)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim dr As SqlDataReader = gip.ExecuteReader
If dr.Read Then
Try
chat.frindname.Text = ListBox1.Text
frindip = dr.Item("myip")
chat.Show()
Catch ex As Exception
MsgBox("هذا العضو لم يسجل دخوله ليتم تحديث معلومات الاتصال به", MsgBoxStyle.Critical, "")
End Try
End If
End Sub
Private Function Break(form As Form) As Boolean
For Each ctrl As Control In form.Controls
If TypeOf ctrl Is Label AndAlso ctrl.Text = listBox1.Text Then
Return True
End If
Next
Return False
End Function
اين المكان الصحيح لوضع الدالة Break
الم يعمل الكود بالشكل المطلوب؟
اخي الكريم اداة القائمة بفورم عرض المسجلين والليبل بفورم اخر اللي هو فورم الدردشة
نحمده ونصلي على رسوله الكريم
جرب المثال التالي ارجو ان يكون مطلبك
(23-01-14, 10:28 PM)ربيع كتب : [ -> ]نحمده ونصلي على رسوله الكريم
جرب المثال التالي ارجو ان يكون مطلبك
ممتاز فعلا قد حصلت على مااريد.