garynevil
Messages postés1Date d'inscriptionlundi 10 juin 2013StatutMembreDernière intervention10 juin 2013
-
Modifié par garynevil le 10/06/2013 à 13:53
Bonjour,
j'ai un problème que je n'arrive pas à contourner.
J'ai une fonction "afficherliste" qu'y est static car je l'utilise dans une autre fonction et pour pourvoir l'appeler je suis obligé de la mettre en static.
De plus cette fonction "afficherliste" doit permettre l'affichage d'une liste ,qu'elle prend en paramétre, dans une ListBox.
Or je ne peux utiliser la Listbox dans la fonction "afficherliste". Pourquoi ?
et comment puis je faire pour faire autrement ?
Merci d'avance pour vos réponses .
Je vous ci-joint le code en question :
public partial class Form1 : Form
{
static ImpinjReader reader = new ImpinjReader();
static List<string> recurence = new List<string>();
static List<string> liste = new List<string>();
static int a = 0;
static int b = 0;
public Form1()
{
InitializeComponent();
// j'essaye d'utiliser listBoX pour afficher chaque nb2 de la liste .
}
MessageBox.Show("c'est fini");
// Stop reading.
reader.Stop();
liste.Clear();
// Disconnect from the reader.
reader.Disconnect();
}
static void OnTagsReported(ImpinjReader sender, TagReport report)
{
// This event handler is called asynchronously
// when tag reports are available.
// Loop through each tag in the report
// and print the data.
// int i = 0 ;
//Console.WriteLine("allo");
liste.Clear();
// recurence.Clear();
foreach (Tag tag in report)
{
recurence.Add(tag.Epc.ToString());
}
foreach (string nb in recurence)
{
a = liste.Count;
if (liste.Contains(nb) == true)
{
}
else
{
liste.Add(nb);
b = liste.Count;
}
if (a == b && a != 1)
{
afficheliste(liste);
}
}
report.Tags.Clear();
{
case "rechercher":
try
{
liste.Clear();
recurence.Clear();
// This example show the minimum program required to read tags.
// If you require more control over the reader settings,
// take a look at the ReadTags example.
// Connect to the reader.
// Change the ReaderHostname constant in SolutionConstants.cs
// to the IP address or hostname of your reader.
reader.Connect("SpeedwayR-10-7f-f3.local");
// Assign the TagsReported event handler.
// This specifies which method to call
// when tags reports are available.