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

VB.NET Discussion :

Enregistrement dans un Datagrid, CollectionViewSource J'y suis presque ><


Sujet :

VB.NET

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut Enregistrement dans un Datagrid, CollectionViewSource J'y suis presque ><
    Bonjour,

    Après de longue recherche, j'ai pu repérer que les "CollectionViewSource " étaient la méthode la plus transparente pour faire fonctionner mon datagrid
    J'affiche 1 champs et lorsque je le modifie il ne s'enregistre pas... Je pense que je doit enregistrer sur le mauvais dataContext Mais je sais pas comment faire...

    J'ai une liaison avec mon LINQ To SQL et une base de donnée SQL Server
    Et j'ai fait une génération automatique des objets
    Voici le code Behind :

    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
    Class MainWindow
     
        Dim _DbAnance As DataClasses1DataContext
        Private Property T_ARBO_FALViewSource As CollectionViewSource
     
        Public Sub New()
     
            ' Cet appel est requis par le concepteur.
            InitializeComponent()
     
            _DbAnance = New DataClasses1DataContext
        End Sub
        Private Sub DataGrid1_CellEditEnding(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridCellEditEndingEventArgs)
            _DbAnance.SubmitChanges()
        End Sub
     
        Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
            T_ARBO_FALViewSource = CType(Me.FindResource("T_ARBO_FALViewSource"), System.Windows.Data.CollectionViewSource)
            'T_ARBO_FALViewSource.Source = New ObservableCollection(Of T_ARBO_FAL)(From Fal In _DbAnance.T_ARBO_FAL)
            T_ARBO_FALViewSource.Source = _DbAnance.T_ARBO_FAL
        End Sub
     
    End Class
    Voici le XamL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ....
    	<Window.Resources>
    		<staticData:FalList  x:Key="FalList"/>
    		<CollectionViewSource x:Key="TASKViewSource" d:DesignSource="{d:DesignInstance staticData:TASK, CreateList=True}" />
            <CollectionViewSource x:Key="T_ARBO_FALViewSource" d:DesignSource="{d:DesignInstance staticData:T_ARBO_FAL, CreateList=True}" />
        </Window.Resources>
    	<Grid x:Name="GridMain" RenderTransformOrigin="0.495,0.536" Height="728" Width="1128" DataContext="{StaticResource TASKViewSource}">
    		<DataGrid AutoGenerateColumns="False" Height="364" HorizontalAlignment="Left" Margin="96,163,0,0" Name="DataGrid1" VerticalAlignment="Top" Width="801" Grid.ColumnSpan="2" Grid.RowSpan="2" ItemsSource="{Binding Source={StaticResource T_ARBO_FALViewSource}}" CanUserAddRows="True">
    			<DataGrid.Columns>
    				<DataGridTextColumn Binding="{Binding Path=FAL_NAME}" Header="Nom de la tache" />
                </DataGrid.Columns>
    		</DataGrid>
    	</Grid>
    ...
    Il y a pas une erreur avec _DbAnance ? alors que j'utilise une CollectionViewSource ?

    Je cherche dans tous les sens mais je suis un peu perdu ...

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Je me demande si la modification n'est pas appliquée à l'objet après l'évènement CellEditEnding... si c'est ça, le SubmitChanges ne fait rien, puisque la valeur n'a pas encore changé.

    Pour vérifier, essaie de mettre un point d'arrêt dans l'évènement, et regarde les propriétés de l'objet pour voir si ça a effectivement changé :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
        Private Sub DataGrid1_CellEditEnding(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridCellEditEndingEventArgs)
            Dim obj As T_ARBO_FAL = CType(e.Row.DataContext, T_ARBO_FAL)
            ' Met un point d'arrêt ici et regarde la valeur de obj
            _DbAnance.SubmitChanges()
        End Sub

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut
    Merci beaucoup après avoir posté j'ai tout refais et ça enregistre .... j'avais du faire une erreur quelque part... Mais pas mal le debug

    Sinon je me demandais à quoi ça servait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    T_ARBO_FALViewSource.Source = New ObservableCollection(Of T_ARBO_FAL)(From Fal In _DbAnance.T_ARBO_FAL)
    Et qu'est ce que ca m'apporterait de plus que faire cela

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    T_ARBO_FALViewSource.Source = _DbAnance.T_ARBO_FAL
    Est-ce que ma façon d'enregistrer serait la même ?

    Merci beaucoup pour ton aide !

  4. #4
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Citation Envoyé par lerieure Voir le message
    Sinon je me demandais à quoi ça servait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    T_ARBO_FALViewSource.Source = New ObservableCollection(Of T_ARBO_FAL)(From Fal In _DbAnance.T_ARBO_FAL)
    Et qu'est ce que ca m'apporterait de plus que faire cela

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    T_ARBO_FALViewSource.Source = _DbAnance.T_ARBO_FAL
    Si tu ajoutes un élément à une ObservableCollection par le code, l'interface graphique le détecte et affiche automatiquement le nouvel élément. Par contre ça ne te dispense pas d'ajouter aussi l'élément au DataContext, sinon il ne sera pas enregistré en base...

    Citation Envoyé par lerieure Voir le message
    Est-ce que ma façon d'enregistrer serait la même ?
    Oui

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut
    Ok ! Donc si je comprend bien peu importe ce que je donne à mon datagrid
    Pour enregistrer dans ma base de données, il faut toujours faire un datacontext sur sa source qui est dans mon cas _DbAnance ?

    Dernière chose, cela devrait faire l'objet d'un nouveau sujet mais j'ai une problème qui traine depuis un moment... toujours à cause de mon problème de compréhension sur l'environnement...

    J'ai donc mon T_ARBO_FAL comme objet qui est mappé sur ma base de données
    et je veux faire une combobox pour pouvoir lister mes FALs (Chaine de montage) depuis mon objet TASK (Tâche) donc j'ai un lien FAL_ID entre les deux tables et mon Datagrid est binder sur TASK

    donc en XAML j'ai fait ceci (Générer automatiquement par mon interface graphique et j'ai selectionné les sources à binder qui doivent être du coup fausses)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <DataGridComboBoxColumn Header="Header" SelectedItemBinding="{Binding Path=FAL_ID}" SelectedValueBinding="{Binding Path=T_ARBO_FAL.FAL_ID}" TextBinding="{Binding Path=T_ARBO_FAL.FAL_NAME}" />
    Le résultat est vide et lorsque j'édite ma combobox est vide ...

    aurais tu une idée ?

    Et merci encore, ce sont des interrogations que je me pose et je trouve pas de réponse. Avec ce que je trouve sur le net, ca marche pas

  6. #6
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Enlève le "T_ARBO_FAL." de tes bindings, vu que ton DataContext est déjà un objet T_ARBO_FAL. Et enlève le SelectedItemBinding, qui entre en conflit avec SelectedValueBinding.

    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    <DataGridComboBoxColumn Header="Header" SelectedValueBinding="{Binding Path=FAL_ID}" TextBinding="{Binding Path=FAL_NAME}" />

    Par contre il faut aussi que tu affectes un ItemsSource au DataGridComboBoxColumn, sinon il sera toujours vide

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut BINDING COMBOBOX
    Enlève le "T_ARBO_FAL." de tes bindings, vu que ton DataContext est déjà un objet T_ARBO_FAL. Et enlève le SelectedItemBinding, qui entre en conflit avec SelectedValueBinding.
    Mon DataContext est TASK

    et je veux faire une combobox pour pouvoir lister mes FALs (Chaine de montage) depuis mon objet TASK (Tâche) donc j'ai un lien FAL_ID entre les deux tables et mon Datagrid est binder sur TASK
    désolé si je le dis pas dans les bon mots

    du coup j'ai fait ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <DataGridComboBoxColumn Header="Header" SelectedValueBinding="{Binding Path=FAL_ID}" TextBinding="{Binding Path=FAL_NAME}" ItemsSource="{Binding Source={StaticResource TASKViewSource}}" />
    Et ca marche pas .... Ce serait pas mon itemsSource ? Il faut que je fasse une classe qui fait la requete ? ou je peux faire une methode dans mon MainWindow et l'appelé dans XAML ?

  8. #8
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Citation Envoyé par lerieure Voir le message
    Mon DataContext est TASK
    Celui du DataGrid, oui, mais chaque ligne (DataGridRow) a un DataContext différent, qui correspond à l'élément représenté par cette ligne.

  9. #9
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut
    ok, Merci je m'étais pas aperçu de ça !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <DataGridComboBoxColumn Header="Fal" SelectedValueBinding="{Binding Path=FAL_ID}" TextBinding="{Binding Path=FAL_NAME}" ItemsSource="{Binding Source={StaticResource TASKViewSource}}" />
    En faisant ça j'ai cette erreur...

    'DeferRefresh' n'est pas autorisé durant une transaction AddNew ou EditItem.

  10. #10
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    Citation Envoyé par lerieure Voir le message
    En faisant ça j'ai cette erreur...

    'DeferRefresh' n'est pas autorisé durant une transaction AddNew ou EditItem.
    Ben fais voir le code qui utilise DeferRefresh

  11. #11
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut
    Je sais pas ce que c'est ...
    Je n'ai pas programmé de DeferRefresh

    j'ai mis en lien les détails de l'erreur...

  12. #12
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    copie/colle la StackTrace de l'exception, là je vois pas d'où ça vient

  13. #13
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut
    L'exception System.InvalidOperationException n'a pas été gérée
    Message='DeferRefresh' n'est pas autorisé durant une transaction AddNew ou EditItem.
    Source=PresentationFramework
    StackTrace:
    à System.Windows.Data.CollectionView.DeferRefresh()
    à System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
    à System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)
    à System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    à System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    à System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    à System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    à System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    à System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
    à System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    à System.Windows.Controls.DataGridHelper.SyncColumnProperty(DependencyObject column, DependencyObject content, DependencyProperty contentProperty, DependencyProperty columnProperty)
    à System.Windows.Controls.DataGridComboBoxColumn.ApplyColumnProperties(ComboBox comboBox)
    à System.Windows.Controls.DataGridComboBoxColumn.GenerateEditingElement(DataGridCell cell, Object dataItem)
    à System.Windows.Controls.DataGridCell.BuildVisualTree()
    à System.Windows.Controls.DataGridCell.OnIsEditingChanged(Boolean isEditing)
    à System.Windows.Controls.DataGridCell.OnIsEditingChanged(Object sender, DependencyPropertyChangedEventArgs e)
    à System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    à System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    à System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    à System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
    à System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
    à System.Windows.DependencyObject.SetValue(DependencyProperty dp, Boolean value)
    à System.Windows.Controls.DataGridCell.BeginEdit(RoutedEventArgs e)
    à System.Windows.Controls.DataGrid.OnExecutedBeginEdit(ExecutedRoutedEventArgs e)
    à System.Windows.Controls.DataGrid.OnExecutedBeginEdit(Object sender, ExecutedRoutedEventArgs e)
    à System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
    à System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
    à System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
    à System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
    à System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
    à System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
    à System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
    à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    à System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
    à System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
    à System.Windows.Input.RoutedCommand.Execute(Object parameter, IInputElement target)
    à System.Windows.Controls.DataGrid.BeginEdit(RoutedEventArgs editingEventArgs)
    à System.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDown(MouseButtonEventArgs e)
    à System.Windows.Controls.DataGridCell.OnAnyMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
    à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
    à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    à System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
    à System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
    à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
    à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    à System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
    à System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
    à System.Windows.Input.InputManager.ProcessStagingArea()
    à System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
    à System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
    à System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
    à System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    à System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.Run()
    à System.Windows.Application.RunDispatcher(Object ignore)
    à System.Windows.Application.RunInternal(Window window)
    à System.Windows.Application.Run(Window window)
    à System.Windows.Application.Run()
    à GestionIntegree.Application.Main() dans C:\Documents and Settings\a807120\Desktop\WpfApplication1\WpfApplication1\obj\x86\Debug\Application.g.vb:ligne 65
    à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Threading.ThreadHelper.ThreadStart()
    InnerException:
    C'est ça ?

  14. #14
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Points : 39 749
    Points
    39 749
    Par défaut
    oui c'est ça... malheureusement ça ne nous apprend pas grand chose, vu que c'est pas dans ton code que le problème se produit

    Là je vois vraiment pas d'où ça vient...

  15. #15
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    205
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2006
    Messages : 205
    Points : 125
    Points
    125
    Par défaut
    Salut !

    J'ai refait une solution plus professionnel copié sur un livre que j'ai acheté sur WPF et ça marche !

    Je fais une classe FalProvider

    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
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports System.Collections.ObjectModel
     
    Public Class FalProvider
        Public Fals As ObservableCollection(Of T_ARBO_FAL)
        Private _dbAnance As AnanceDataContext = New AnanceDataContext
     
        Public Sub New()
            Fals = New ObservableCollection(Of T_ARBO_FAL)
            Dim FalList = From LaFal In _dbAnance.T_ARBO_FAL
            For Each MaFal In FalList
                Fals.Add(MaFal)
            Next
        End Sub
     
    End Class
    Puis une classe FalViewProvider

    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
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports System.Collections.ObjectModel
     
    Public Class FalViewProvider
        Private Property FalProvider As FalProvider = New FalProvider
        Public ReadOnly Property Fals As ObservableCollection(Of T_ARBO_FAL)
            Get
                Return FalProvider.Fals
            End Get
        End Property
     
    End Class
    (Méthode MVVM)

    Enfin j'instancie mon FalViewProvider dans mon MainWindow
    Dans la ressource du XamL je fais le lien avec mon FalViewProvider
    Et graphiquement je crée mon Combobox à partir des "columns" dans les proprietés de mon datagrid

    Voila, je suis heureux ! Maintenant je vais devoir justifier que j'ai passé 2jours pour faire apparaitre une "combobox" dans un tableau

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

Discussions similaires

  1. [Débutant] Souci d'enregistrement dans un datagrid
    Par Attila54 dans le forum VB.NET
    Réponses: 6
    Dernier message: 15/02/2012, 20h48
  2. Réponses: 2
    Dernier message: 13/03/2009, 17h28
  3. Réponses: 3
    Dernier message: 11/09/2007, 14h00
  4. ajout dynamique d'enregistrements dans un datagrid
    Par sb.aida dans le forum ASP.NET
    Réponses: 1
    Dernier message: 16/04/2007, 14h10
  5. [VB.NET]Suppression d'un enregistrement dans un DataGrid
    Par San Soussy dans le forum ASP.NET
    Réponses: 4
    Dernier message: 16/06/2005, 10h30

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