Adding radiobutton with a button

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
antoineA
Posts: 20
Joined: Fri Dec 02, 2011 8:22 am

Adding radiobutton with a button

Post 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.

User avatar
Ron L.
Posts: 214
Joined: Fri Jul 15, 2011 3:21 pm

Re: Adding radiobutton with a button

Post 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.
Best Regards,

Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer

iva
Posts: 13
Joined: Sat May 04, 2013 7:23 am

Re: Adding radiobutton with a button

Post 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.

Eric
Posts: 3
Joined: Tue May 21, 2013 1:40 am

Re: Adding radiobutton with a button

Post by Eric »

Hi Iva,

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

Eric

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Adding radiobutton with a button

Post 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.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply