Page 1 of 1

AnalogNumeric Control loop

Posted: Sat Feb 06, 2021 7:17 am
by Aurimas94
Hello, given the example viewtopic.php?f=9&t=1493#top I am unable to make same loop through AnalogNumeric controls. Can someone help with this?
here is the code I have:

Code: Select all

	using Neo.ApplicationFramework.Controls.Script;
	
	public partial class FSystemInfo
	{
		
		void Button1_Click(System.Object sender, System.EventArgs e)
		{
			
			AnalogNumericCFAdapter myTxt = GetTextBox("an_ABC");
			myTxt.Value = 2;
		}
		
		public AnalogNumericCFAdapter GetTextBox(string txtName){
			
			Type FormType = this.GetType();
			FieldInfo field = FormType.GetField(txtName,BindingFlags.NonPublic | BindingFlags.Instance);

			if( field != null ){
			    
				Neo.ApplicationFramework.Controls.Controls.Label lb;
				lb = (Neo.ApplicationFramework.Controls.Controls.Label) field.GetValue(this);
				AnalogNumericCFAdapter myTxt;
				myTxt = this.AdapterService.CreateAdapter<Neo.ApplicationFramework.Controls.Script.AnalogNumericCFAdapter>(lb);
				return myTxt;
			}
			return null;
			
		}
	}
In here "an_ABC" is the AnalogNumeric. When you run application it throws an exception that "Object ref not set to an instance of an object".