|
||
|
|
#1 (permalink) |
|
Forum Expert
|
Code:
foreach (RadioButton ctrl1 in panel1.Controls)
{
RadioButton rb1;
List<RadioButton> rbs = new List<RadioButton>();
if ((RadioButton)ctrl1.Checked = true)
{
rbs.Add(ctrl1);
rb1 = rbs.IndexOf(0);
string text;
text = rb1.Text;
Affin type1 = (Affin)Enum.Parse(typeof(Affin), text, true);
type1 = attacker.Affinity;
Continue = true;
textBox1.Text = "1";
}
}
__________________
Procrastinators unite!
Tomorrow. Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders. ![]() |
|
|
|
|
|
#2 (permalink) | |
|
Forum Expert
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
|
Quote:
Code:
List<RadioButton> rbs = new List<RadioButton>(); If so, you might want to re-examine Code:
rbs.Add(ctrl1);
rb1 = rbs.IndexOf(0);
|
|
|
|
|
|
|
#3 (permalink) |
|
Forum Expert
|
Code:
List<RadioButton> radbutton = new List<RadioButton>();
foreach (RadioButton ctrl1 in panel1.Controls)
{
radbutton.Add(ctrl1);
foreach (RadioButton ctrl in radbutton)
{
if (ctrl.Checked)
{
string text;
text = ctrl.Text;
Affin type1 = (Affin)Enum.Parse(typeof(Affin), text, true);
type1 = attacker.Affinity;
Continue = true;
textBox1.Text = "1";
}
}
}
It doesn't crash when I do it; It just doesn't set the affinity correctly.
__________________
Procrastinators unite!
Tomorrow. Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders. ![]() |
|
|
|
|
|
#5 (permalink) |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
|
Ok, not sure if this is what you are looking for, but this works and does what I think you need:
Code:
List<RadioButton> rbs = new List<RadioButton>();
void CheckRadioButtons()
{
foreach (RadioButton rb in panel1.Controls)
{
if (rb.Checked == true)
{
rbs.Add(rb);
string text = rb.Text;
Affin type = (Affin)Enum.Parse(typeof(Affin), text, true);
return;
}
}
}
![]() And im curious to what this list of radio buttons is for since there really isnt a reason to store them in a list since only one will ever be checked... Also, what Outkast said is also a problem with your code ![]()
__________________
Useful links (Use them or die in a fire!!!): Ultimate Little Guide, C# Tutorials & Docs, RunUO Basic Scripts, Run UO How to..., Configure server for connections, Scripting for Dummies, Common Problem Solutions, FAQ Forum, RunUO Wiki, Basic Generics, Xml Tutorial Last edited by mordero; 03-28-2007 at 11:45 PM. |
|
|
|
|
|
#6 (permalink) |
|
Forum Expert
|
I really didn't know how else to do it. But I got it fixed, every code there worked, but the
Code:
type1 = attacker.Affinity; I feel so stupid at times. Is there a better way to find which one of them was checked? I couldn't think of one.
__________________
Procrastinators unite!
Tomorrow. Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders. ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|