C#
public Form2(string title,string txt)
{
InitializeComponent();
this.Text = title;
label1.Text = txt;
}
VB.Net
Public Sub New(ByVal sTitle As String, ByVal sText As String)
InitializeComponent()
Me.Text = sTitle
Me.Label1.Text = sText
End Sub
InitializeComponent
Passing values step by step
Add another form (Form2) in the project and add Label control on it
And we are passing these two textbox values from Form1 to Form2
Here, call the constructor of Form2 and pass these values and set these values in form2
C# Source Code
Form1using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string nTitle = textBox1.Text;
string nText = textBox2.Text ;
Form2 frm = new Form2(nTitle, nText);
frm.Show();
}
}
}
Form2 using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
}
public Form2(string title,string txt)
{
InitializeComponent();
this.Text = title;
label1.Text = txt;
}
}
}
VB.Net Source Code
Form1Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sTitle As String
Dim sText As String
sTitle = TextBox1.Text
sText = TextBox2.Text
Dim frm As New Form2(sTitle, sText)
frm.Show()
End Sub
End Class
Form2 Public Class Form2
Public Sub New(ByVal sTitle As String, ByVal sText As String)
InitializeComponent()
Me.Text = sTitle
Me.Label1.Text = sText
End Sub
End Class
Windows Forms
Windows programmers have made extensive use of forms to build user interfaces. Each time you create a Windows application, your Visual Studio will display a default blank form, onto which you can drag and drop controls from the Toolbox window. More about.... C# Forms and VB.Net FormsForm on Top of All Other Windows
You can bring a Form on top of an application by simply setting the Form.topmost form property to true will force the form to the top layer of the screen. More about.... How to keep Form on Top of All Other WindowsMDI Form
A Multiple Document Interface (MDI) programs can display multiple child windows inside them. This is in contrast to single document interface (SDI) applications, which can manipulate only one document at a time. More about.... C# MDI FormNEXT.....Autocomplete TextBox
0 Comments
Good day precious one, We love you more than anything.