TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohamed Moumni
NA
48
8.4k
Why do I find the result repeats after the search?
Jun 28 2017 3:28 PM
i use this methode to search for every keyword in textbox1 ind have the result in the listbox2 . But the problem that the results are repeated .
this code used in search button
private
void
button1_Click(
object
sender, EventArgs e)
{
// the keyword in text box
string
[] pattern = textBox1.Text.Split(
new
[] {
' '
},StringSplitOptions.RemoveEmptyEntries);
// list_temporare for items in listbox 1
List<DirectoryInfo> list_temporare =
new
List<DirectoryInfo>();
// listbox2 for show result
listBox2.Items.Clear();
// add all items in listbox1 in list_temporare (Because linq and lambda does not support the items in the box list or that what I believe)
foreach
(DirectoryInfo dr
in
listBox1.Items)
{
list_temporare.Add(dr);
}
// search for every key word in pattern
var liste_resultat = (from drc
in
list_temporare
where pattern.All(s => drc.ToString().ToLower().Contains(s.ToLower()))
select drc);
// show result in listbox2
foreach
(DirectoryInfo dr
in
liste_resultat)
{
listBox2.Items.Add(dr);
}
}
Reply
Answers (
1
)
HOW TO SAVE IMAGE IN FOLDER AFTER CREATE SETUP IN C# WIN APP
AutoMapper Issue