-
Oct 13th, 2014, 04:43 PM
#1
Thread Starter
Lively Member
[RESOLVED] How would I access a button on another form?
I have a class 'WeaponSelection' which needs to check if the radio button on my menuselection form is checked.
example:
Weapon Class:
Code:
if (rdbRyu.checked == true)
{
do this..
}
the rdbRyu radio button is located in the menuselection form
-
Oct 13th, 2014, 05:05 PM
#2
Re: How would I access a button on another form?
To be frank, it would be wrong for that class to do that. It's possible but it's not good practice.
Presumably the form is creating this object in the first place so the form should be passing the Boolean value to the object rather than the object retrieving it from the form. If you can provide more information about the relationship between the form and the object then we can provide more information on what might be the best way to move the data.
If you really want the object to retrieve the data then it is possible. In order for the object to use the RadioButton, it must have a reference to that RadioButton. That is almost certainly going to come from the form that contains it. The form is going to have to pass the object a reference to the RadioButton or a reference to itself that the object can then use to access the RadioButton. That second option also requires that the RadioButton be exposed publicly, which makes things even worse. If the form is going to passing a reference anyway, why not just pass the Boolean in the first place?
-
Oct 14th, 2014, 04:06 AM
#3
Re: How would I access a button on another form?
Yeh as JMC said i would avoid doing it.
Get the value of your radiobutton (true/false) and pass it in to your class probably via a property.
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
-
Oct 14th, 2014, 10:32 AM
#4
Thread Starter
Lively Member
Re: How would I access a button on another form?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|