Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Need some help - enabling checkboxes filter_list
Author
Message
RE: Need some help - enabling checkboxes #21
(03-17-2013, 04:28 AM)cxS Wrote:
(03-17-2013, 03:09 AM)i0xIllusi0n Wrote: Why wouldn't it return an error though saying Form2 checkbox doesn't exist?

Because it does exist lol....

On Form1, not Form2. If form2 is running the code, and it's suppose to enable a checkbox on Form2, why doesn't it say the Form2 checkbox doesn't exist
[Image: BAvhP6h.png]
Code:
[5:42:25 PM] i0xillusi0n: Breshie don't bust a nut over chloe now
[5:42:31 PM] Entity: fapfapfapfapfapfapfapfapfapfap
[5:42:33 PM] Jigglypuff | SL: EWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Reply

RE: Need some help - enabling checkboxes #22
Because as I said, it exists.

If there is a CheckBox on Form1. You instantiate and show a new form (Form2), when you instantiate a new instance of Form1 from a method embedded in the Form2 class, it's no different than how you have Form1 set up in the designer. It's a clone of that blueprint of Form1...

Sorry, I was just going by what you're saying, but *Form1 (or Form2 as in your post)... It doesn't matter, if there is a CheckBox on that form, if you instantiate the form that has a CheckBox in it, it exists. That's all there is to it, doesn't matter if the form is hidden, not shown. The only time it wouldn't exist is if the control was removed from that form as it's parent container, or if the form itself doesn't exist at that point in time, because if it doesn't exist, any of the control children will not exist either.

The issue is this:
Code:
Form1 frm = new Form1();

If you declare a new instance of Form1, how is this new instance, supposed to reference the original?
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply

RE: Need some help - enabling checkboxes #23
Adopt my example of passing the reference to Form1 in Form2's constructor when it is shown and then keep a record of that in a private variable so you can have a gateway to modify the Form1 instance directly from the Form2 instance. There's no possible way you're going to change anything on Form1 just by doing that, unless you iterate through the collection of open forms with the property Application.OpenForms, and find Form1 in this collection to use as the reference to make the modifications to.

Example of that:
Code:
foreach (Form f in Application.OpenForms)
{
    if (f.Name == "Form1")
    {
        f.Controls["label1"].Text = "Something else to fire the TextChanged event...";
    }
}

Application.OpenForms returns a FormCollection which inherits a class that implements the IEnumerable interface, therefore you can use the foreach context on the collection to iterate through each internal Form and validate things that way.
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply







Users browsing this thread: 1 Guest(s)