acces textbox from another form
Hello :) I have two forms and i want to acces in the main form a textbox which is placed in the second form..but the textbox isn't visible for the main form. how can i do that? thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 20, 2013, 6:06 PM
Violeta PopaPosted Mar 20, 2013, 4:47 PM
but i keep getting this error for the bolded line and i can't understand why
"Object reference not set to an instance of an object."
mos martinPosted Mar 17, 2013, 1:11 PM
VulpesPosted Mar 17, 2013, 1:07 PM
mos martinPosted Mar 17, 2013, 9:31 AM
for example in the datagrid i have
1
2
3
4
5
if my selected row is 3, click next and record no 4 is shown, but when i click next again doesn't show 5, it's still 4.
VulpesPosted Mar 16, 2013, 4:38 PM
Try this instead:
private void pictureBox1_Click(object sender, EventArgs e)
{
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "..";
conn.Open();
Acasa main = (Acasa)Application.OpenForms["Acasa"];
DataGridView dgv = main.clientGridView;
int i = dgv.CurrentRow.Index;
int maxRows = dgv.Rows.Count;
if (i != maxRows - 1)
{
i++;
textBox1.Text = dgv.Rows[i].Cells[0].Value.ToString();
textBox2.Text = dgv.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dgv.Rows[i].Cells[2].Value.ToString();
textBox4.Text = dgv.Rows[i].Cells[3].Value.ToString();
textBox5.Text = dgv.Rows[i].Cells[4].Value.ToString();
dgv.Rows[i].Selected = true;
dgv.Rows[i -1].Selected = false; // make sure only a single row is selected
}
else
{
MessageBox.Show("..");
}
conn.Close(); // move this to the end so you always close the connection
}
mos martinPosted Mar 16, 2013, 1:49 PM
i really appreciate your help..
VulpesPosted Mar 16, 2013, 9:25 AM