Page 1 of 1

How can I get control's Name in form

Posted: Thu Aug 19, 2010 1:57 am
by RickyHuang
this is my button click event
-----------------------------------------
foreach (RadioButton obj in PanelControl2.Control.Controls)
{
MessageBox.Show(obj.Name); <----------------i got value: ""
MessageBox.Show(CustomerID.Name);<------i got value:CustomerID
if(obj.Checked)
{
var = obj.Name;
break;
}
}
---------------------------------------

CustomerID is a Radio Button

How can i got name when i use foreach?

and

If I dont want the form1.show how to do can let buttonOk click event in form1.load?


How can I get control's Name in form

Posted: Thu Aug 19, 2010 5:15 am
by Alex K.
Hello,

Use the following code:

Code: Select all

foreach (StiRadioButtonControl obj in PanelControl1.Components)
{
	MessageBox.Show(obj.Name);
        if(obj.Checked)
        {
               var = obj.Name;
               break;
        }
}
Thank you.

How can I get control's Name in form

Posted: Thu Aug 19, 2010 6:25 am
by Alex K.
Hello,
RickyHuang wrote: If I dont want the form1.show how to do can let buttonOk click event in form1.load?
ButtonControl1_Click(null, EventArgs.Empty);
Form1.Visible = false;

Thank you.

How can I get control's Name in form

Posted: Thu Aug 19, 2010 7:38 pm
by RickyHuang
it can work...

thanks a lot..:feelgood:

How can I get control's Name in form

Posted: Thu Aug 19, 2010 10:25 pm
by Andrew
Great! Have a good day!