تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] معرفة الفورم الذي تم وضع عليه الاداة
#1
السلام عليكمورحمة الله
عند صناعة اداة جديدة اريد ان اعرف الفورم الذي تم وضع الاداة عليه لاقوم بعمل تغيرات به
عند صناعة UserControl كنت استخدم ParentForm
انما لو انا بعمل كمبو بوكس مثلا لم اجد ParentForm
وجزاكم الله خيرا


قمة الاستعباط ومحدش يضحك عليا

كود :
Public Class Class1

    Inherits ComboBox

    Private _ParentForm As Form
    Public Property ParentForm() As Form
        Get
            Return _ParentForm
        End Get
        Set(ByVal value As Form)
            _ParentForm = value
        End Set
    End Property


    Public WithEvents dd As New UserControl

    Public Sub New()
        With dd
            .Visible = False
            .Size = New Size(0, 0)
            .Show()
        End With
        Me.Controls.Add(dd)
    End Sub

    Private Sub dd_Load(sender As Object, e As EventArgs) Handles dd.Load
        Me.ParentForm = dd.ParentForm
    End Sub

End Class

الموضع كده بقي حكاية

كود :
Public Class Class1

    Inherits ComboBox

    Private _ParentForm As Form
    ''' <summary>الفورم الذي تم وضع الاداة عليه</summary>
    Public Property ParentForm() As Form
        Get
            Return _ParentForm
        End Get
        Set(ByVal value As Form)
            _ParentForm = value
        End Set
    End Property


    Private WithEvents UserContro As New UserControl With {.Size = New Size(0, 0), .Visible = False}

    Public Sub New()
        UserContro.Show()
        Me.Controls.Add(UserContro)
    End Sub

    Private Sub UserContro_Load(sender As Object, e As EventArgs) Handles UserContro.Load
        Me.ParentForm = UserContro.ParentForm
    End Sub

End Class
الرد }}}
تم الشكر بواسطة:
#2
كود :
Dim cntrl as Control =  Me.Parent
        Do While(Not cntrl Is  Nothing)
            If typeof(cntrl) is Form Then
                exit do
            Else
                cntrl =  cntrl.Parent                
            End If
            
        loop
        if not cntrl is  nothing then MsgBox (cntrl.Name )
الرد }}}
تم الشكر بواسطة: ali.alfoly
#3
كود :
' This example uses the Parent property and the Find method of Control to set
    ' properties on the parent control of a Button and its Form. The example assumes
    ' that a Button control named button1 is located within a GroupBox control. The  
    ' example also assumes that the Click event of the Button control is connected to
    ' the event handler method defined in the example.
    Private Sub button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        ' Get the control the Button control is located in. In this case a GroupBox.
        Dim control As Control = button1.Parent
        ' Set the text and backcolor of the parent control.
        control.Text = "My Groupbox"
        control.BackColor = Color.Blue
        ' Get the form that the Button control is contained within.
        Dim myForm As Form = button1.FindForm()
        ' Set the text and color of the form containing the Button.
        myForm.Text = "The Form of My Control"
        myForm.BackColor = Color.Red
    End Sub
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [سؤال] عدم القدر على اخفاء الفورم عند بدء التشغيل؟؟ ABDULLAH HASSAN 10 223 26-04-24, 02:26 PM
آخر رد: ABDULLAH HASSAN
  [VB.NET] معرفة الخطا MOHAMMED ALZWI 0 71 15-04-24, 01:56 PM
آخر رد: MOHAMMED ALZWI
  [VB.NET] معرفة الخطا MOHAMMED ALZWI 2 67 15-04-24, 01:54 PM
آخر رد: MOHAMMED ALZWI
  [VB.NET] حفظ الفورم (Form) (البرنامج) بعد التغيير visualist2015 8 6,511 12-04-24, 04:07 AM
آخر رد: أبو جودة
  معرفة رصيدي للهاتف النقال المتصل بالكمبيوتر وارسال رسائل نصية منه AHMED213 1 162 03-04-24, 08:08 AM
آخر رد: sdz
Photo [VB.NET] مشكلة في شكل الفورم abuyazan 5 325 27-02-24, 09:38 PM
آخر رد: aljzazy
  [VB.NET] معرفة بيانات الجهاز محمد بوقزاحة 1 335 21-02-24, 11:44 PM
آخر رد: AHMED213
  معرفة عدد مرات تكرار الاسم في الداتاقريدفيو صالح عبدالله 8 468 05-02-24, 04:39 PM
آخر رد: صالح عبدالله
  [VB.NET] مشكلة ظهور textbox بعد حذفه من الفورم مبرمج صغير 1 1 270 27-01-24, 02:04 AM
آخر رد: مبرمج صغير 1
  [VB.NET] معرفة بيانات الجهاز محمد بوقزاحة 7 689 12-01-24, 07:31 PM
آخر رد: Kamil

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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم