Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Apply button click function on a a single row records of a listview

$
0
0

i have a listview with buttons on each row i want to open csv files of the the name of the row concerned, i match the the name of the fournisseur with the name of the csv file if it's a match the button in the row of this fournisseur should open the file.

here is my code : 


 private void OpenFile_OnClick(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < listView.Items.Count; i++)
            {
                dynamic currentItemInLoop = listView.Items[i];
                String frs = (String)currentItemInLoop.fournisseur;
                DateTime myDate = (DateTime)currentItemInLoop.date;
                string myPath = @"C:\Users\DefaultAccount\Desktop\Projet Top Of Travel\FichiersCSV\";
                string fac = "Facture_";
                string filename = string.Format(frs);
                filename = Regex.Replace(filename + " " + myDate, @"[^0-9a-zA-Z]", " ");
                string finalPath = System.IO.Path.Combine(myPath, fac + filename + ".csv");
                string[] dirs = Directory.GetFiles(@"C:\Users\DefaultAccount\Desktop\Projet Top Of Travel\FichiersCSV\", "*.csv");
                if (finalPath.Contains(frs))
                {
                    Process.Start(finalPath);
                }
            }
        }
<GridViewColumn Header="Fichier CSV" Width="360"><GridViewColumn.CellTemplate><DataTemplate><Button x:Name="OpenFile" Content="Open File" Click="OpenFile_OnClick" Width="350"/></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>