none
showdialog - how to manually copy text from parent form in vb.net RRS feed

  • Question

  • Hi I have an application where i need to copy product id from parent form when child form is active. this I want to achieve using ShowDialog() not Show().
    Monday, August 19, 2019 4:49 PM

All replies

  • This can be done with a new constructor e.g.

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim productId As Integer = 22
            Dim f As New Form2(productId)
            f.ShowDialog()
        End Sub
    End Class

    Child form sets the value from the new constructor to a private variable to use.

    Public Class Form2
        Private ProductIdentifier As Integer
        Public Sub New(ByVal pProductIdentifier)
            InitializeComponent()
            ProductIdentifier = pProductIdentifier
        End Sub
    End Class
    If you need to pass a string then simply change the Integer items to String.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Monday, August 19, 2019 5:08 PM
    Moderator
  • i want to manually copy when child form is active.
    Monday, August 19, 2019 5:09 PM
  • i want to manually copy when child form is active.
    Copy from where? You best option unless I misunderstood your question is to use what I provided since the child form is modal active means moving from your app to another then back to your app again as the parent form is not accessible when showing the child form using ShowDialog.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, August 19, 2019 5:12 PM
    Moderator