dynamic ListBox Created.

dynamic ListBox Created.

I created a combo box using ActiveX.
I received an "unknown name" error when trying to check the selected item
public void Macro_Init_CombBox()
{
try
{
//Get the zenon Element
zenOn.IElement zElementActivX = this.Project.DynPictures().Item("top").Elements().Item("ActiveX_1");
//Set the zenon AktiveX Element as ComboBox Control
Microsoft.Vbe.Interop.Forms.ComboBox combo = zElementActivX.AktiveX() as Microsoft.Vbe.Interop.Forms.ComboBox;
object defaultParameter = null;
//Fill the ComboBox with Items
int y = 1970;
string a = DateTime.Now.ToString("yyyy");
int lastYear = Convert.ToInt32(a);
object k = 1970;
int asdf = 0;
for (y = 1970; y <= lastYear; y++)
{
k = y;
defaultParameter = asdf;
combo.AddItem(ref k, ref defaultParameter);
asdf++;

}

}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("ERROR Macro_Init(): "
+ ex.Message + " " + ex.Source);
}
}
public void Macro_seletedItems()
{
try
{
zenOn.IElement zElementActivX = this.Project.DynPictures().Item("top").Elements().Item("ActiveX_1");
Microsoft.Vbe.Interop.Forms.ComboBox combo = zElementActivX.AktiveX() as Microsoft.Vbe.Interop.Forms.ComboBox;
string temp = combo.SelText; //error

}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("ERROR Macro_Init(): "
+ ex.Message + " " + ex.Source);
}
}



I changed the way WPF.
But controls are invisible

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:System.Windows"
mc:Ignorable="d"
Name="MainWindow"
Height="350" Width="525">



This is a migrated post! Originally posted on 07.06.2017 by user jahyun100. Please be aware that information can be outdated.