تقييم الموضوع :
  • 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
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  مشكلة في عرض الفورم بالحجم المحدد مصمم هاوي 1 249 29-09-25, 03:17 AM
آخر رد: مصمم هاوي
  [VB.NET] حفظ تنسيق الفورم ثم تطبيقة علي فورم اخر فيجوال بيسك abo ragab 7 1,220 09-07-25, 12:45 AM
آخر رد: abo ragab
  إغلاق الفورم مع حذف جميع البيانات الموجودة به صالح عبدالله 10 1,041 19-04-25, 08:54 PM
آخر رد: Kamil
  كيف يمكن تحريك الفورم بأستخدام زر heem1986 2 587 30-03-25, 01:58 AM
آخر رد: heem1986
  [سؤال] تغيير الفورم الرئيسي عند تشغيل البرنامج في Visual Studio مع .NET 8؟ silverlord 2 654 09-03-25, 03:52 AM
آخر رد: silverlord
  ماهو سبب اغلاق الفورم صالح عبدالله 2 514 26-02-25, 02:40 PM
آخر رد: صالح عبدالله
  استفسار عن تنسيق الفورم في حالة تغيرالفورم من وضع العادي الي التكبير fireswored1 4 824 22-01-25, 09:04 PM
آخر رد: fireswored1
  برنامج الفيجول استوديو 2010 لا يتجاوب مع التحديثات التي اجريها عليه في برمجة البرامج PeterGhattas082460 1 422 14-12-24, 01:16 AM
آخر رد: Taha Okla
  كيفية معرفة الجهاز رئيسي ام فرعي المتألق9 1 398 13-11-24, 06:41 PM
آخر رد: justforit
  تأخر فتح الفورم بالبنال لمدة طويلة F.H.M 1 351 13-11-24, 08:27 AM
آخر رد: F.H.M

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


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