hi all!i have a form which has a group box and inside the group box have five radio buttons(one is selected by default).At the same time it also have a "OK" button at the form.So when i click on "Ok" button it will sent the value out..Does anybody can provide my some guideline or code..Thanks in advance!
Loading
SolitairePosted Aug 17, 2005, 9:37 PM
You didn't state the language. Here is a sample written in VB:
Private Sub btnSelect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSelect.Click
Dim radnumg As Integer
Select Case True
Case rdoGroup1.Checked
radnumg = 1
Case rdoGroup2.Checked
radnumg = 2
Case rdoGroup3.Checked
radnumg = 3
Case rdoGroup4.Checked
radnumg = 4
Case rdoGroup5.Checked
radnumg = 5
End SelectIf radnumg = 0 Then
lblGroup.Text = "No group radio button is checked."
Else
lblGroup.Text = "Group Radio Button # " & radnumg.ToString() & " is checked."
End If
End Sub
and in C#:
private void btnSelect_Click(ByVal sender As System.Object,
{ByVal e As System.EventArgs) Handles btnSelect.Click;
int radnumg = 0;
if (true == rdoGroup1.Checked)
{
radnumg = 1;
}
else if (true == rdoGroup2.Checked)
{
radnumg = 2;
}
else if (true == rdoGroup3.Checked)
{
radnumg = 3;
}
else if (true == rdoGroup4.Checked)
{
radnumg = 4;
}
else if (true == rdoGroup5.Checked)
{
radnumg = 5;
}
if (radnumg == 0)
{
lblGroup.Text = "No group radio button is checked.";
}
else
{
lblGroup.Text = "Group Radio Button # " + radnumg.ToString() + " is checked.";
}
}