Page 1 of 1

Adding radiobutton with a button

Posted: Wed Dec 14, 2011 7:38 am
by antoineA
Hi,

I'm new in C# and I have a problem.
I have a screen 1 (called "ecranSave") which contains one button. When I click on this button, it adds radiobuttons.
However, when I change screen and I go back to screen 1, radiobuttons disappear.

This is the sample code I have written :

Code: Select all

    
public partial class ecranSave
    {				
		public void addProg(string nom, int X, int Y)
		{	
			RadioButton radio = new RadioButton();
			radio.BackColor = Color.Transparent;
			radio.Text = nom;
			radio.Location = new Point(X,Y);
			this.Controls.Add(radio);
		}
		
		void Button1_Click(System.Object sender, System.EventArgs e)
		{
			string nom_prog = Globals.Tags.nomProgEnCours.Value;
			this.addProg(nom_prog,Globals.Tags.XPositionRadio.Value, Globals.Tags.YPositionRadio.Value + Globals.Tags.nbProg.Value * 20);
			Globals.Tags.nbProg.Value ++;
		}			
    }
Where is the problem?

Thanks for your answer (and sorry for my English!!)

Best regards,
antoineA.

Re: Adding radiobutton with a button

Posted: Wed Dec 14, 2011 9:39 am
by Ron L.
Whenever you change screens in iX Developer, that instance of the screen you were seeing is released to the garbage collector and erased. You may want to consider adding the radio button to the screen in the Opened action.

Re: Adding radiobutton with a button

Posted: Sun May 26, 2013 12:58 am
by iva
Hi everybody!
I am trying to use this example for runtime objects creating too.
But on line:

Code: Select all

 this.Controls.Add(...);
I have gotten an error:
'Neo.ApplicationFramework.Generated.EngineState' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type ...

Does anybody know what could be the reason ?
EngineState - it is the name of my screen.

Re: Adding radiobutton with a button

Posted: Fri Sep 06, 2013 3:53 am
by Eric
Hi Iva,

I have the same problem. Did you already found a solution?

Eric

Re: Adding radiobutton with a button

Posted: Fri Sep 06, 2013 10:40 am
by mark.monroe
You can only add controls to the screen using "this.Controls.Add(..." if you are targeting a Windows CE unit. Otherwise you have to look into WPF programming to figure out how to add controls if you are targeting a PC.