Hi Tobias,
You need to do some things, first you have make accesible the checkboxes to
the other class, you can do this by declaring them as public, later you need
to pass a reference for the form1 object to the constructor or a method of
the controller class, or if you use only one instance of form1 you can
declare the checkboxes as static and then you do not have to pass the
reference to the object.
Said that, I would suggest you what I think is a better way, I would not
create a separate class for this, I would implement that functionality
inside the Form1 class, I would create an array ( an ArrayList in case you
need to add/remove some of them in code ) with the reference to the
checkboxes to be able to deal with them as a group, instead of specifying
each one by name. You can create then functions as UncheckAll that would
looks like this:
public void SetCheckBoxStatus( bool checked)
{
foreach( CheckBox checkbox in checkboxarray )
{
checkbox.Checked = checked;
}
}
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Tobias Froehlich" <re*******@gmx.net> wrote in message
news:hp********************************@4ax.com...
Hi,
I have a form called form1 on which there are a lot of checkBoxes
(they form a 8x6 field). I'd like to create a class in a seperate .cs
file which gives some control over these checkBoxes (for example to
make them all unchecked).
So I now created a .cs file for this class, but I can't access the
checkBox elements on form1. They are both in the same namespace by the
way. What do I need to do? I tried to access it via Form1.CheckBox1
and CheckBox1. I did not use inheritance, do i need to?
Thanks in advance.
PS: Yes i am a newbie :)