Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if (radioButton1.Checked == true && textBox1.Text.ToString() == "read")
{
this.Hide();
Form1 fm = new Form1();

fm.ShowDialog();
------- fm.pictureBox31.Visible = false;

}


Nothing happen in pictureBox31
Posted

Just create a property in the new form which does that for you:

C#
public class Form1: Form
   {
   ...
   public bool ShowImage
      {
      get { return pictureBox31.Visible; }
      set { pictureBox31.Visible = value; }
      }
   ...
   }
And set it's value before the call to ShowDialog:
C#
Form1 fm = new Form1();
fm.ShowImage = false;
fm.ShowDialog();

If you use ShowDialog, then the call does not return until the form is closed, so the setting of it's properties must be done before you display the form.

You could use Show instead, but then you'd want to add a FormClosed event handler to detect when the user closes it, and either re-display your old form, or close the application.

BTW: Do yourself a favour, and stop using Visual Studio default names for everything - you may remember that "TextBox8" is the mobile number today, but when you have to modify it is three weeks time, will you then? Use descriptive names - "tbMobileNo" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbMobile" in three keystrokes, where "TextBox8" takes thinking about and 8 keystrokes...
 
Share this answer
 
Comments
Member 11280947 4-Jun-15 5:31am    
Thank You
OriginalGriff 4-Jun-15 5:52am    
You're welcome!
Hello ,
If you want to hide the picture box then write that code in Form1_Load event , not in current form .
 
Share this answer
 
Comments
Member 11280947 4-Jun-15 5:31am    
Thank You

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900