How to pass value from one form to another form
How to pass value from one form to another form
Abstract:-
How to pass value from one form to another form using windows applicaiton.
Step 1:-
Click File-->New-->Project then click new project window will display
and choose vb.net or c# then give name to it.
Step 2:-
Right click the project name and click Add -->Windows form
Step 3:-
In Form 1 just drag and drop one button and textbox control.In button click event just create the object for form2.
Step 4:-
Just drag and drop one textbox control to show the form1 textbox value and click the textbox then go to the property window change the property of modifiers to public(Default is private).
Take the below code and check it.
C# Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.textBox1.Text = textBox1.Text.ToString();
f2.Show();
}
}
}
VB.Net Code
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f2 As New Form2
f2.TextBox1.Text = TextBox1.Text
f2.Show()
End Sub
End Class
but what if i want to transfer value using a string. i just want to store that value on another form.
how to do that.