Click here to Skip to main content
15,867,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 6 radiobuttons within a frame. I would like to scroll through the radiobuttons and know what the selected radiobutton text is. It is different from Visual Studio C#. I'm developing in Monodevelop.
Thanks.

Taveira

What I have tried:

I have some Windows applications developed in C# and I'm looking to move to Linux. I'm trying to adapt these programs to Monodevelop. But some things don't exist in Mono.
Posted
Updated 29-Dec-21 5:49am
Comments
Patrice T 29-Dec-21 12:04pm    
What about reading the documentation ?

Mono controls generally work the same as in Windows: the raise an Even which you handle. The event handler method gets two parameters: the sender and the EventArgs. The former is the control (or other class) instance that raised the event.

So if you have the handler method for three RadioButtons on a Form, the sender will get one of three instances depending on which the user clicked.
 
Share this answer
 
The routine in Visual Studio is like this:
foreach (Control ctrl in panel1.Controls)
{
if (ctrl is RadioButton)
{
RadioButton radioB = (RadioButton)ctrl;
if (radioB.Checked)
{
strCargos = radioB.Text;
}
}
}

In mono there are no Controls.
I've done a lot of research and I still don't have the solution. If you have the solution, can you pass me?
Thanks.
 
Share this answer
 
v2
Comments
OriginalGriff 29-Dec-21 14:04pm    
Reason for my vote of one: "In mono there are no Controls."
Read your own code:
foreach (Control ctrl in panel1.Controls)

If there are no Controls, what type do you think "ctrl" is? Since you wrote the code, you presumably were awake when you typed it?
After a lot of trial and error, I got it. Here's the solution.

foreach (Gtk.RadioButton ctrl in table3)
{
    if (ctrl != null && ctrl.Active)
    {
        numsorteio = Convert.ToInt32(ctrl.Label);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900