En cliquant sur un identifiant, le titre, s'affiche dans un textBox

Résolu
danny243 Messages postés 74 Date d'inscription   Statut Membre Dernière intervention   -  
danny243 Messages postés 74 Date d'inscription   Statut Membre Dernière intervention   -
salut à tous j'ai un combox qui contient les id de chaque enregistrement de ma base des données que j'ai mis dans une datagrid et j'aimerai à ce que lorsque je selectionne un élement dans le combobox qu'il affiche le titre du film associé à l'id dans un textbox , l'année aussi
sauf que quand je fais un selectedIndex et ensuite j'assigne une valeur à ma textBox ça ne marche pas voici mon code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using BLL;


namespace UIL
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

    
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
          
            Film.ChargerListeEtudiant();
            dgFilm.ItemsSource = Film.films;
         
        }

        private void LigneDG_dblClick(object sender, MouseButtonEventArgs e)
        {

        }

        private void cboIds_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Film f = new Film();
//c'est ici mon problème 
            if (cbolds.SelectedIndex==1)
            {
                txt_Titre.Text =f.Titre ;
            }

        }

        private void Loaded_Cbolds(object sender, RoutedEventArgs e)
        {
            cbolds.ItemsSource = Film.films;
        }
    }


}





1 réponse

Utilisateur anonyme
 
Mais non.

Ton combobox contient les films et affiche leur id (enfin si tu as fait comme je t’ai proposé hier).
Dans le xaml tu bindes le textblock sur l’élément sélectionné du combobox avec le chemin qui correspond à la propriété que tu veux
0
danny243 Messages postés 74 Date d'inscription   Statut Membre Dernière intervention  
 
ah d'accord
0