passing data from textbox to datagridview [Resolved]

Posted by Aarviii under VB.NET on 3/29/2013 | Points: 10 | Views : 4389 | Status : [Member] | Replies : 7

How can I pass data from my textboxes (in form1) to my DataGridView (in form2)?





Responses

Posted by: Satyapriyanayak on: 3/31/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Form1.cs

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();

}
public Form1(string myString)
{
InitializeComponent();

if (myString != null)
dataGridView1.Rows[0].Cells[0].Value = myString;
}

private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.ShowDialog();
}

}
}



Form2.cs

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 Form2 : Form
{

public Form2()
{
InitializeComponent();

new Form1().Close();
}

private void button1_Click(object sender, EventArgs e)
{
Form1 frm1 = new Form1(textBox1.Text);
frm1.ShowDialog();
this.Close();
}



}
}




If this post helps you mark it as answer
Thanks

If this post helps you mark it as answer
Thanks

Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 3/31/2013 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
hi
try this

private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(textBox1.Text);
frm2.Show();
}

public Form2(string qs)
{
InitializeComponent();

textBox1.Text = qs;
}

Mark as Answer if its helpful to you

Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 3/29/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

can u ask clearly ?

Mark as Answer if its helpful to you

Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Aarviii on: 3/29/2013 [Member] Starter | Points: 25

Up
0
Down

THIS IS THE SEQUENCE. THERE WAS 2 FORMS
1.) OPEN THE PROGRAM FORM1 WILL APPEAR
2.) FILL UP THE FORM.
3.) CLICK SUBMIT. THERE IS A MESSAGE BOX FOR CONFIRMATION
4.) IF YOU CLICK YES THEN FORM2 WILL APPEAR AND IT HAS THE DGV. CONTAINING THE DATA YOU INPUT FROM FORM1

THE PROBLEM IS I CAN'T CALL THE DATA FROM FORM1 TO FORM2 IN THE DATAGRIDVIEW.


Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Aarviii on: 3/30/2013 [Member] Starter | Points: 25

Up
0
Down
[b] UP UP UP[/b]

Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Aarviii on: 3/30/2013 [Member] Starter | Points: 25

Up
0
Down
[b] up. please some help here.[/b]

Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jopito on: 4/2/2013 [Member] Starter | Points: 25

Up
0
Down
while at the submit button,declare his code
form2.show()
me.hide()

Mark as answer if satisfied

Aarviii, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response