Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7524663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:07:45+00:00 2026-05-30T03:07:45+00:00

I’ve a vb .net winform that is show by others forms. I’ve frmA.vb, frmB.vb,

  • 0

I’ve a vb .net winform that is show by others forms. I’ve frmA.vb, frmB.vb, frmC.vb and frmD.vb.

This all forms can call frmItem.vb.
frmItem.vb allows the user to select an item from a Database, this item is sent by calling a Set Property on the parent.

i.e.

I open frmA, click on button (something like:)

  fi = new frmItem(frmA) 'frmItem has 4 New() methods, frmA.. b... c and d
  'i need to pass the correct parent.
  fi.showModal()

So, when i add an item, it calls

  fA.addItem(item_id)

It works OK, my doubt is about optimization, because i’ve duplicated frmItem; one copy managed frmA and frmB, and the other one, frmC and frmD.

i.e.

in frmItem1 when i’ve to sent the item, i use:

private fB as frmB
private fA as frmA



if parentFrmA is nothing then
   'Is frmB
   fB.addItem(item_id)
else
   'Is frmA
   fA.addItem(item_id)
end if

And, on frmItem2:

private fC as frmC
private fD as frmD



if parentFrmC is nothing then
   'Is frmD
   fD.addItem(item_id)
else
   'Is frmC
   fC.addItem(item_id)
end if

If i modify frmItem1, i’ve to modify frmItem2 and viceversa, because they should look and act like one.

All four forms, have the same Set Property, but like they’re differents forms, i can’t use a unique Form class in frmItem.

Is the posibility that one form, can manage multi parents in an easy way??

If you need more info, let me know. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:07:46+00:00Added an answer on May 30, 2026 at 3:07 am

    I can’t completely follow your example since, well, I think it’s just hard to follow.

    But in general, it sounds like these child forms should just be raising an event that the parent form is listening for. That way, you can separate your concerns a bit and not hardcode these dependencies.

    You can try making your own EventArgs class to follow best practices:

    Public Class ChildFormEventArgs
      Inherits EventArgs
    
      Private _ItemID As Integer
    
      Public Sub New(ByVal itemID As Integer)
        _ItemID = itemID
      End Sub
    
      ReadOnly Property ItemID() As Integer
        Get
          Return _ItemID
        End Get
      End Property
    End Class
    

    Your child forms would have a public event and you would raise it when ever this “added” thing happens:

    Public Class Form2
      Public Event ItemAdded(ByVal sender As Object, ByVal e As ChildFormEventArgs)
    
      Private _ItemID as Integer
    
      Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        RaiseEvent ItemAdded(Me, New ChildFormEventArgs(_ItemID))
      End Sub
    End Sub
    

    And then your parent form is the one listening and can act accordingly:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
      Using testForm As New Form2()
        AddHandler testForm.ItemAdded, AddressOf ChildForm_ItemAdded
        testForm.ShowDialog(Me)
        RemoveHandler testForm.ItemAdded, AddressOf ChildForm_ItemAdded
      End Using
    End Sub
    
    Private Sub ChildForm_ItemAdded(ByVal sender As Object, ByVal e As ChildFormEventArgs)
      '// do something here.
      '// sender is the child form that called it
      '// e is the event arguments that contains the ItemID value
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.