B
Baldeep
Hi,
I'm implementing a component that is similar in
functionality to RadioButton. Basically it's a
RadioButton with a different visual representation and it
allows the developer to pick a maximum number of
simultaneously selected buttons. (So instead of just
allowing 1 of n buttons to be checked, you can allow 2 of
n buttons to be checked, etc.)
My question isn't really about how to implement that kind
of control. Rather, I'm curious to know how
RadioButton "know" to uncheck themselves when another
RadioButton in the same group is checked. Does each
RadioButton just go through the Parent.Controls collection
when it is checked? Maybe something like this?
RadioButton rb;
foreach (Control c in this.Parent.Controls)
if (typeof(c) == typeof(this))
{
rb = (RadioButton)(c);
if (rb.Checked)
rb.Checked = false;
}
Seems like there should be a better way to do this..
Would this get slow if the Parent.Controls collection were
large?
Thanks in advance,
Baldeep
I'm implementing a component that is similar in
functionality to RadioButton. Basically it's a
RadioButton with a different visual representation and it
allows the developer to pick a maximum number of
simultaneously selected buttons. (So instead of just
allowing 1 of n buttons to be checked, you can allow 2 of
n buttons to be checked, etc.)
My question isn't really about how to implement that kind
of control. Rather, I'm curious to know how
RadioButton "know" to uncheck themselves when another
RadioButton in the same group is checked. Does each
RadioButton just go through the Parent.Controls collection
when it is checked? Maybe something like this?
RadioButton rb;
foreach (Control c in this.Parent.Controls)
if (typeof(c) == typeof(this))
{
rb = (RadioButton)(c);
if (rb.Checked)
rb.Checked = false;
}
Seems like there should be a better way to do this..
Would this get slow if the Parent.Controls collection were
large?
Thanks in advance,
Baldeep