[QUOTE=jahyun100;15501]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.
I do not know how to put an item in a Combobox in C #.
<test.xaml>
<UserControl x:Class="System.Windows.Controls.UserControl"
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.Controls"
mc:Ignorable="d"
re"> Name="MainWindow"
Height="350" Width="525">
<Grid Name="myGrid" Width="525" Height="350" Background="#212121">
<Button x:Name="button" Content="BUTTON" HorizontalAlignment="Left" Height="38" Margin="300,110,0,0" VerticalAlignment="Top" Width="79" Foreground="White" Background="#212121"/>
<ComboBox x:Name="comboBox" HorizontalAlignment="Left" Height="30" Margin="88,110,0,0" VerticalAlignment="Top" Width="157"/>
</Grid>
</UserControl>