Results 1 to 6 of 6

Thread: Calling Events Dynamically In VB.net

  1. #1
    Join Date
    Nov 2009
    Posts
    117

    Calling Events Dynamically In VB.net

    Hello, I am learning VB.net programming and currently I am searching for the program or code which can help me call the events Dynamically. I have searched on internet, but not find anything useful. So, if anyone is having solution for it, then please provide me solution for it. I will be thankful to you.

  2. #2
    Join Date
    May 2008
    Posts
    2,393

    Re: Calling Events Dynamically In VB.net

    Hello, I have a code which will simply provide you help for getting solution for dynamic button event. Check it whether it is important for your or not.
    Code:
     $(input.classbouton).click(function() 
    { 
        / / Use here $ (this) to have a jquery instance that represents the button.
        / / Example:
        alert( $(this).attr('id') ); / / Displays the ID attribute of the button clicked
      });

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Calling Events Dynamically In VB.net

    Must add your button to the form. It may be only way to solve your problem. So, just take look at the code below and you will able to get the solution for it.
    Code:
    this.Controls.Add (this.button );
    
    this.button. Click + = new System.EventHandler (this.button_CLICK);
    
    private void button_CLICK (Object sender, System.EventArgs e)
            {
    / / Action
            }

  4. #4
    Join Date
    Feb 2008
    Posts
    1,856

    Re: Calling Events Dynamically In VB.net

    Hey, I have done following for it.
    I first started doing:
    Code:
    var onclick = document.createAttribute("onclick");
    onclick.nodeValue = "myFunction ()";
    document.getElementById('myElement').setAttributeNode(onclick);
    Then in the coding I have changed the following:
    Code:
    try {
      document.getElementById('myElement').attachEvent(myFunction,true)
    } catch (e) {
      var onclick = document.createAttribute("onclick");
      onclick.nodeValue = "myFunction ()";
      document.getElementById('myElement').setAttributeNode(onclick);
    }
    And at last my code is as following :
    Code:
    / / set my settings
    document.getElementById('myElement').onclick = function onsenfou (event) {
      myFunction(mesParamètres);
    };

  5. #5
    Join Date
    Apr 2008
    Posts
    1,949

    Re: Calling Events Dynamically In VB.net

    I am not having knowledge about the vb.net. but, I have got the code below which will help you to create a menuitem dynamically. I think the logic of it will be helpful to you for calling the events dynamically.
    Code:
    private void menu_Selection_Select (object sender, EventArgs e)
            {
    this.m_selection_materiel.MenuItems.Clear ();
    Am ArrayList = new ArrayList (); / / am for array_materiel
               
    MenuItemExtend mnu;
    
    foreach (ListViewItem mon_item in list_Liste_Fichiers.Items)
                {
    if (! am.Contains (mon_item.SubItems [6]. Text))
                    {
    am.Add (mon_item.SubItems [6]. Text);
                    }
                }
    am.Sort ();
    foreach (string material in am)
                {
    mnu = new MenuItemExtend ();
    mnu.Text = material;
    mnu.Tag = material;
    mnu.Click + = new EventHandler (mnu_Click);
    this.m_selection_materiel.MenuItems.Add (mnu);
                }
            }
    
    protected void mnu_Click (object sender, EventArgs e)
            {
    selectionner_par_materiel ((string) ((MenuItemExtend) sender). Tag);
            }
    
            private void selectionner_par_materiel (string material)
            {
    foreach (ListViewItem mon_item in list_Liste_Fichiers.Items)
                {
    if (mon_item.SubItems [6]. == Text material)
                    {
    mon_item.Checked True =;
                    }
                }
            }
    
    public class MenuItemExtend: menuItem
    {
    private object tag;
    public object Tag
        {
    get (return tag;)
    set (tag = value;)
        }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,015

    Re: Calling Events Dynamically In VB.net

    If you want to implement the event then you must need to follow the procedure of the steps below:
    • First thing you need to do is the declaration of the delegate.
    • Then you need to provide the event signature and for that you can make use of the Event keyword.
    • Then you can handle that event by declaring an event handler.

Similar Threads

  1. How to calculate value dynamically in JavaScript?
    By KAIRU26 in forum Software Development
    Replies: 5
    Last Post: 24-02-2010, 10:01 PM
  2. Not able to Include files dynamically in ASP
    By DANIEL 602 in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 12:32 AM
  3. Dynamically Loading a C# DLL
    By Allan.d in forum Software Development
    Replies: 3
    Last Post: 23-11-2009, 06:54 AM
  4. How to set the maxlength of the textboxes dynamically
    By Sophia in forum Software Development
    Replies: 3
    Last Post: 18-03-2009, 12:00 AM
  5. How to add forms Dynamically with JavaScript
    By Neil'o in forum Software Development
    Replies: 3
    Last Post: 12-03-2009, 01:12 PM

Posting Permissions

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