Showing results 1 to 3 of 3

Thread: dynamic ListBox Created.

  1. #1
    Join Date
    23.05.2017
    Posts
    3

    Default 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
    <test.xaml>
    <Window x:Class="System.Windows.Window"
            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"
    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>
    </Window>
     
    Attached Thumbnails Attached Thumbnails wpf.png  

  2. #2
    Join Date
    23.05.2017
    Posts
    3

    Default Re: dynamic ListBox Created.

    [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>



  3. #3
    Join Date
    22.03.2010
    Posts
    18

    Default Re: dynamic ListBox Created.

    Hi!

    Do you really need to make the listbox/combobox in code instead of the one provided as a dynamic element in zenon?
    You can dynamically fill it with text/values by using a string-variable.

Similar Threads

  1. ListBox VSTA
    By loanvar in forum VSTA
    Replies: 3
    Last Post: 1st April 2015, 07:03
  2. Convert runtime created fpm.cmp
    By brc in forum zenon Supervisor
    Replies: 4
    Last Post: 9th May 2013, 03:25
  3. Replies: 1
    Last Post: 20th February 2011, 23:31
  4. Replies: 0
    Last Post: 1st July 2010, 08:17
  5. automatically created limits
    By markclemens in forum zenon Supervisor
    Replies: 0
    Last Post: 20th August 2007, 10:21

Tags for this Thread

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •