Hello, well basically, i created a windows form application when i started my project and i have created two extra forms (options and about). The options tab has a few checkbox's like: minimize to tray and top-most program and in my main form i have the code:
if (this.WindowState == FormWindowState.Minimized == true) { notifyIcon1.Visible = true; this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; }
|
but i want to do something like
if (this.WindowState == FormWindowState.Minimized == true && Options.checkBox1.Checked == true) { notifyIcon1.Visible = true; this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; }
|
but i can't find a way to read the properties of the controls on form3(Options), i tried changing the controls in the designer code portion of the form from private to public, but still no success. I would really appreciate any help on this topic. Thanks in advance.
Kirtan PatelPosted Oct 18, 2009, 2:19 PM
Enc RyptPosted Oct 18, 2009, 2:26 PM
Enc RyptPosted Oct 18, 2009, 2:12 PM
on the Form "f", i tried putting Form f = new form(); before the code and it didn't help. it shows the contents of f as "null"
Kirtan PatelPosted Oct 18, 2009, 1:33 PM
Serban CosminPosted Oct 18, 2009, 1:22 PM
Enc RyptPosted Oct 18, 2009, 1:21 PM
Kirtan PatelPosted Oct 18, 2009, 12:55 PM
Here is code for what you are trying to do Here Requirement is Your Options Form Should Be Open to Access the
CheckBox in It :)
dont forget to mark "Do you like this answer" if my answer helped you :)
Step 1
Make CheckBox1's Property "Modifire = "Public" in Options Form like below image
Then Write Code Like Below Where ever you want to access CheckBox
//Get CheckBox1State in Options
Form f = Application.OpenForms["Options"];
bool CheckBox1State = ((Options)f).checkBox1.Checked;
if (this.WindowState == FormWindowState.Minimized == true && CheckBox1State == true)
{
notifyIcon1.Visible = true;
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
}