|
-
Aug 24th, 2004, 10:18 AM
#1
Thread Starter
Frenzied Member
copying text input from one form to the other
Hello,
I have 2 forms and l want to be able to copy text inputs from one form to the other form. In Visual Basic this was very easy to do. e.g. txtStudentID.Text = frmNewStudent.txtNewStudentID.text.
But i am not sure how to do this in C#.
Can any one tell me.
Thanks in advance,
Steve
-
Aug 24th, 2004, 09:57 PM
#2
Fanatic Member
assuming you instantiated the form2 and declared textbox1 of form2 as public. you can do like this.
Code:
Form2 f=new Form2();
private void Form1_Load(object sender, System.EventArgs e)
{
f.Show();
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
f.textBox1.Text=textBox1.Text;
}
-
Aug 25th, 2004, 08:03 AM
#3
Thread Starter
Frenzied Member
Hello,
Thanks for you reply.
I think l will do it the way that you said.
Just another question, l am creating a small database application for a small library system. I have 2 tables books and students.
The properties of students are: StudentID, Name, Address, Email. I have never done a database application using c#. Just on the student table, how can l make that oop, for example adding, updating and deleting.
I find it easy to do it the vb way.
Any example programs or tutorials.
Many thanks in advance.
Steve
-
Sep 21st, 2004, 02:41 AM
#4
Hyperactive Member
hi there...try this.
for the insert (adding) method.
VB Code:
/// <summary>
/// Button Save
/// </summary>
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection cn=new SqlConnection("your connection here....");
cn.Open();
String cmdText="insert into Student (StudentID,xname,address,xmail) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";
SqlCommand cm=new SqlCommand(cmdText,cn);
cm.ExecuteNonQuery();
cn.Close();
}
hope it helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|