Solved

Passing texbox values between forms

Posted on 2008-06-19
4
176 Views
Last Modified: 2013-11-26
I am developing an application that when you click on an icon on the form, a text box populates another form which has a larger version of the same text box with a larger font to allow ease of editing.  After the editing is completed on the expanded text box, I want to pass the new text back to the original text box.  I can do it by hard coding the reference to the original text box in the expanded text box form but I would like to reuse the expanded textbox form on other text boxes and other forms within the application.  Any help greatly appreciated.
0
Comment
Question by:ameybusiness
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 24

Expert Comment

by:mankowitz
ID: 21823611
Essentially, what you want to do is create a new form with a single, large text box that can be called up whenever you need it.

Add a handler for every textbox on your original form. (use the Enter event . When the user enters that text box, have it call up the larger text box at the same location as the current textbox. When the user leaves the new text box, make it invisible and copy the text property into the original text box.
0
 

Author Comment

by:ameybusiness
ID: 21824693
Thansk for the help.  
I got it working for one text box copying the text back to the original text box when I call the form_closing event.  My problem is I would like to re-create this for all text boxes on multiple forms.  Is there a way I can pass the form name and textbox name to the expanded form so that I can reference them when passing back the changed text - or is tehre an easier way to do this?
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 21824791
Open the second form using ShowDialog().
This makes code STOP in the calling form until the dialog is closed.
To close the dialog, set the DialogResult property to OK or Cancel.
You can then check this value in the calling form and react accordingly.

Example:
Public Class frmEdit
 
    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub
 
    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
 
End Class
 
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fe As New frmEdit
        fe.TextBox1.Text = Me.TextBox1.Text
        If fe.ShowDialog = Windows.Forms.DialogResult.OK Then
            Me.TextBox1.Text = fe.TextBox1.Text
        End If
    End Sub
 
End Class

Open in new window

0
 

Author Closing Comment

by:ameybusiness
ID: 31468844
Worked perfectly.  I copied in to a function that I use in all of my forms.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question