What's new

Help how to code to search bar searching on listbox "showdialog"

m0stwanted143

Eternal Poster
Joined
Feb 8, 2016
Posts
924
Reaction
189
Points
333
Nahihirapan ako mag code sa searching sa listbox gumagana lang sya kapag nag add ka ng items sa mismong forms, pero kapag sa nag add ka ng items sa files or "Showdialog" di sya ma search bakit kaya?? Need kaya database ?
 
Maybe query problem.
post your code. Let's see what's the problem

Pa help po ito yung code ko .

private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();

if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) ;
{

//this.textBox_path.Text = openFileDialog1.FileName(paths.GetFileName());
}
}
1603434185638.png
 

Attachments

Sa Mismong Properties ng list lang yung gumagana pag nakaka search. kaya binura ko nalng .. need ko po ung pag nag lagay na po ako ng files tapos ma sesearch ko po pag ni run ko na po.. Thanks and Advance..
 
Do you mean? gusto mo yung inaadd mo na item ay masesave? then iloload yung nakasaved na list items pag open ng proram?
 
Post your search code
private void textBoxSeach_TextChanged(object sender, EventArgs e)
{


if (string.IsNullOrEmpty(textBoxSearch.Text) == false)
{

foreach (string str in listcollection)
{
if (str.StartsWith(textBoxSearch.Text))
{
listBox1.Items.Add(str);
}
}
}
else if (textBoxSearch.Text == "")
{
listBox1.Items.Clear();
foreach (string str in listcollection)
{
listBox1.Items.Add(str);
}
}
}
 
private void textBoxSeach_TextChanged(object sender, EventArgs e)
{


if (string.IsNullOrEmpty(textBoxSearch.Text) == false)
{

foreach (string str in listcollection)
{
if (str.StartsWith(textBoxSearch.Text))
{
listBox1.Items.Add(str);
}
}
}
else if (textBoxSearch.Text == "")
{
listBox1.Items.Clear();
foreach (string str in listcollection)
{
listBox1.Items.Add(str);
}
}
}
1603436059504.png
 

Attachments

Teka, you want, kapag nagsearch ka yung result lang ang matitira? and then clear yuing ibang items?
Tapos pag empty na yung search box, marerestore yung items?
 

Similar threads

Back
Top