Closed Thread
Results 1 to 2 of 2

Thread: Issue on populating a selected value in one form from another form..see my code.

  1. #1
    yasinirshad is offline Newbie
    Join Date
    Nov 2007
    Posts
    3
    Rep Power
    0

    Issue on populating a selected value in one form from another form..see my code.

    Hi..I have 2 forms in my vb.net windows application. I select a value in form2 and want to populate it in textbox in form1 but its not getting populated. In form2 i have a listbox whose values are binded from db.
    Form1:
    Code:
    Public Class frmNCNpopup
        Inherits System.Windows.Forms.Form
        Public FR As frmNCNtest = Nothing
    <STAThread()> _
        Private Shared Sub main()
            Application.Run(New frmNCNpopup)
        End Sub
    Private Sub btn_openchild_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_openchild.Click
            FR = New frmNCNtest
            Dim dr As DialogResult = FR.ShowDialog(Me)
            If dr = DialogResult.OK Then
                txt_test3.Text = FR.ListBox1.SelectedItem.ToString()
            End If
            FR.Dispose()     
        End Sub
    Form2:
    Code:
    Public Class frmNCNtest
        Inherits System.Windows.Forms.Form
    Public WithEvents ListBox1 As System.Windows.Forms.ListBox
    Private Sub btn_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_submit.Click
            Me.Close()
        End Sub
    When i use selectedindexchanged event in form2, and click on button in form1, then form2 never opens at all.sometimes it shows System.Data.DataRowView in form1 textbox.
    Code:
    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            Me.Close()
        End Sub
    How can i select a value from listbox in form2 and show it in textbox in form1?
    Thanks.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    anglina's Avatar
    anglina is offline Learning Programmer
    Join Date
    Jan 2009
    Location
    Vientiane, Laos
    Posts
    76
    Rep Power
    0

    Re: Issue on populating a selected value in one form from another form..see my code.

    Something like

    Code:
    textbox1=Form2.Listbox1.SelectedItem
    imacooknotachef.com
    Food/Photo Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. TextBox watermark clear form issue
    By j.lai in forum JavaScript and CSS
    Replies: 4
    Last Post: 02-10-2011, 04:50 PM
  2. PHP and Javascript form issue
    By SirBee in forum PHP Development
    Replies: 11
    Last Post: 06-24-2010, 01:27 PM
  3. form background to the selected colour
    By mosgba in forum Visual Basic Programming
    Replies: 10
    Last Post: 12-12-2008, 09:11 AM
  4. Replies: 1
    Last Post: 11-19-2007, 09:42 AM
  5. Tableless form issue
    By skalber in forum JavaScript and CSS
    Replies: 0
    Last Post: 10-12-2007, 06:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts