IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langages Discussion :

Conversion d'une procédure c# en vb


Sujet :

Langages

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de stdebordeau
    Homme Profil pro
    Statisticien
    Inscrit en
    Septembre 2007
    Messages
    241
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44

    Informations professionnelles :
    Activité : Statisticien
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2007
    Messages : 241
    Par défaut Conversion d'une procédure c# en vb
    Bonjour,

    je sèche sur la réécriture de la procédure suivante en vb.net, surtout sur la partie du eventhandler.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
            private static void ExpandSubContainers(ItemsControl parentContainer)        {
                foreach (Object item in parentContainer.Items)
                {
                    TreeViewItem currentContainer = parentContainer.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
                    if (currentContainer != null && currentContainer.Items.Count > 0)
                    {
                        //expand the item
                        currentContainer.IsExpanded = true;
     
     
                        //if the item's children are not generated, they must be expanded
                        if (currentContainer.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
                        {
                            //store the event handler in a variable so we can remove it (in the handler itself)
                            EventHandler eh = null;
                            eh = new EventHandler(delegate
                                {
                                    //once the children have been generated, expand those children's children then remove the event handler
                                    if (currentContainer.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                                    {
                                        ExpandSubContainers(currentContainer);
                                        currentContainer.ItemContainerGenerator.StatusChanged -= eh;
                                    }
                                });
     
     
                            currentContainer.ItemContainerGenerator.StatusChanged += eh;
                        }
                        else //otherwise the children have already been generated, so we can now expand those children
                        {
                            ExpandSubContainers(currentContainer);
                        }
                    }
                }
            }
    Bonnes volontés, pouvez vous m'aider avec l'équivalent de la procédure en vb.net

    Merci d'avance

  2. #2
    Membre Expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Par défaut
    ça peut peut-être t'aider : http://converter.telerik.com/

  3. #3
    Membre éclairé Avatar de stdebordeau
    Homme Profil pro
    Statisticien
    Inscrit en
    Septembre 2007
    Messages
    241
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44

    Informations professionnelles :
    Activité : Statisticien
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2007
    Messages : 241
    Par défaut
    Merci, mais je l'avais déjà essayé et ça ne marche pas, spécialement sur la partie du eventhandler

  4. #4
    Membre éclairé Avatar de stdebordeau
    Homme Profil pro
    Statisticien
    Inscrit en
    Septembre 2007
    Messages
    241
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44

    Informations professionnelles :
    Activité : Statisticien
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2007
    Messages : 241
    Par défaut
    suffisait d'utiliser les expressions lambda. Ci dessous la bonne formulation :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
        Private Sub ExpandSubContainers(parentContainer As ItemsControl)        For Each item As [Object] In parentContainer.Items
                Dim currentContainer As TreeViewItem = TryCast(parentContainer.ItemContainerGenerator.ContainerFromItem(item), TreeViewItem)
                If currentContainer IsNot Nothing AndAlso currentContainer.Items.Count > 0 Then
                    'expand the item
                    currentContainer.IsExpanded = True
     
     
                    'if the item's children are not generated, they must be expanded
                    If currentContainer.ItemContainerGenerator.Status <> GeneratorStatus.ContainersGenerated Then
                        'store the event handler in a variable so we can remove it (in the handler itself)
                        Dim eh As EventHandler = Nothing
                        'once the children have been generated, expand those children's children then remove the event handler
                        eh = New EventHandler(Sub()
                                                  If currentContainer.ItemContainerGenerator.Status = GeneratorStatus.ContainersGenerated Then
                                                      ExpandSubContainers(currentContainer)
                                                      RemoveHandler currentContainer.ItemContainerGenerator.StatusChanged, eh
                                                  End If
                                              End Sub)
     
     
                        AddHandler currentContainer.ItemContainerGenerator.StatusChanged, eh
                    Else
                        'otherwise the children have already been generated, so we can now expand those children
                        ExpandSubContainers(currentContainer)
                    End If
                End If
            Next
        End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. passage d'un nom de table dans une procédure stockée
    Par thierry V dans le forum MS SQL Server
    Réponses: 7
    Dernier message: 26/07/2010, 16h48
  2. Conversion d'une procédure du script shell vers le batch dos
    Par marlenjp dans le forum Autres Logiciels
    Réponses: 2
    Dernier message: 12/10/2006, 14h42
  3. Erreur de conversion et requête dynamique dans une procédure
    Par franculo_caoulene dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 01/08/2005, 15h12
  4. Problème avec une procédure stockée
    Par in dans le forum Langage SQL
    Réponses: 4
    Dernier message: 27/05/2003, 15h33
  5. Fin de programme dans une procédure
    Par Sinclair dans le forum Langage
    Réponses: 13
    Dernier message: 29/11/2002, 22h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo