jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Mon Jul 23, 2007 4:56 pm Post subject: passing data to an event |
|
|
I have these functions,
Code: | private void CreateProjectAndChildren()
{
PClassStr =
[
" ",
" Project",
"Quote",
"Language",
"Technical",
"TimeKeeper"
];
PSubClassStr =
[
" ",
" Project",
"PM",
"SW-Trans",
"DOC-Trans",
"DTP",
"Validation",
"Proofing",
"In-Context",
"XTranslate",
"QA",
"Pre-Proc",
"Post-Proc",
"Analysis",
"VoiceOver",
"Interpretation",
"Support",
"TimeTrack"
];
with(EmailForm = new Form)
{
text = "Choose SubProject Category";
GroupBox myGroup;
RadioButton[char[]] SubProjRadio;
TextBox myTextBox;
Button Done;
width = 270;
startPosition = FormStartPosition.CENTER_SCREEN;
formBorderStyle = FormBorderStyle.FIXED_DIALOG; // Don't allow resize.
maximizeBox = false;
// Add a GroupBox.
with(myGroup = new GroupBox)
{
bounds = Rect(4, 4, EmailForm.clientSize.width - 8, 120); // Set the x, y, width, and height.
text = "Choose one of these SubProject options..."; // Text displayed at the top of the box.
parent = EmailForm; // Set myGroup's parent to this Form.
}
// Add some RadioButton`s to the GroupBox myGroup..
int pcY = 18;
char[] lastpc;
foreach (char[] pc; PClassStr)
{
if (pc == " " || pc == " Project")
continue;
else
{
with(SubProjRadio[pc] = new RadioButton)
{
bounds = Rect(6, pcY, 160, 13); // x, y, width and height within the GroupBox.
text = pc; // Text displayed next to the selector thing.
checked = false; //
parent = myGroup; // Set parent to the GroupBox.
}
pcY += 18;
lastpc = pc;
}
}
// Update myGroup's height to fit all the RadioButtons.
// The client size is the area inside the control, excluding the border.
myGroup.clientSize = Size(myGroup.clientSize.width, SubProjRadio[lastpc].bottom + 6);
// Add a button and a click event handler.
with(Done = new Button)
{
location = Point(EmailForm.clientSize.width - Done.width - 4, myGroup.bottom + 4); // width/height are default.
text = "&Done";
parent = EmailForm;
click ~= &Done_click;
}
// Update the Form's height to fit all the controls.
// The client size is the area inside the Form, excluding the border and caption.
clientSize = Size(clientSize.width, Done.bottom + 6);
show();
}
}
// Click handler for voteBtn.
private void Done_click(Object sender, EventArgs ea)
{
char[] s;
char[][] comments;
RadioButton voteOption;
// See which option they voted for.
foreach (char[] pc; PClassStr)
{
if (myGroup.SubProjRadio[pc].checked)
{
msgBox(pc);
break;
}
}
error.text = "Must choose one of the options...";
}
|
which works fine until I click the Done button. I need to know what option the user chose, but I can not seem to find a way to do this. I guess I could use buttons and create a click function for each button, but there is gotta be an easier way. How can I pass "myGroup.SubProjRadio" array to the Done_click event? I have spent a few hours on this and I can not seem to find a way. Of course, I am new to this Windows Programming Idea, but it should not be that hard!
thanks,
jose |
|